mirror of
https://github.com/reactos/reactos.git
synced 2024-08-07 19:58:21 +00:00
Almost done removing old tests
svn path=/trunk/; revision=11370
This commit is contained in:
parent
d8a803d10b
commit
24617fc41e
|
@ -1,28 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <WinError.h>
|
||||
#include <WinDNS.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
PDNS_RECORD QueryReply, AddrResponse;
|
||||
DWORD Addr;
|
||||
|
||||
assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
|
||||
NULL, &QueryReply, NULL) == ERROR_SUCCESS);
|
||||
AddrResponse = QueryReply;
|
||||
while( AddrResponse ) {
|
||||
if( AddrResponse->wType == DNS_TYPE_A ) {
|
||||
Addr = ntohl( AddrResponse->Data.A.IpAddress );
|
||||
printf( "www.reactos.com == %d.%d.%d.%d\n",
|
||||
(int)(Addr >> 24) & 0xff,
|
||||
(int)(Addr >> 16) & 0xff,
|
||||
(int)(Addr >> 8) & 0xff,
|
||||
(int)Addr & 0xff );
|
||||
}
|
||||
AddrResponse = AddrResponse->pNext;
|
||||
}
|
||||
DnsRecordListFree( QueryReply, DnsFreeRecordList );
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = dnsquery
|
||||
|
||||
TARGET_SDKLIBS = dnsapi.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,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,52 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <ntddk.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("TickCountLow: %lx\n",
|
||||
SharedUserData->TickCountLow);
|
||||
printf("Drives: ");
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
printf("%c", (SharedUserData->DosDeviceMap & (1 << i))?'1':'0');
|
||||
}
|
||||
printf("\n");
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
if (SharedUserData->DosDeviceMap & (1 << i))
|
||||
{
|
||||
printf("%c: ", 'A'+i);
|
||||
switch(SharedUserData->DosDeviceDriveType[i])
|
||||
{
|
||||
case DOSDEVICE_DRIVE_UNKNOWN:
|
||||
printf("Unknown\n");
|
||||
break;
|
||||
case DOSDEVICE_DRIVE_CALCULATE:
|
||||
printf("No root\n");
|
||||
break;
|
||||
case DOSDEVICE_DRIVE_REMOVABLE:
|
||||
printf("Removable\n");
|
||||
break;
|
||||
case DOSDEVICE_DRIVE_FIXED:
|
||||
printf("Fixed\n");
|
||||
break;
|
||||
case DOSDEVICE_DRIVE_REMOTE:
|
||||
printf("Remote\n");
|
||||
break;
|
||||
case DOSDEVICE_DRIVE_CDROM:
|
||||
printf("CD-ROM\n");
|
||||
break;
|
||||
case DOSDEVICE_DRIVE_RAMDISK:
|
||||
printf("Ram disk\n");
|
||||
break;
|
||||
default:
|
||||
printf("undefined type\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n\n");
|
||||
return 0;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
# $Id: makefile,v 1.7 2003/11/14 17:13:16 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = dump_shared_data
|
||||
|
||||
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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,649 +0,0 @@
|
|||
/* Edit Control Test for ReactOS, quick n' dirty. Very rigid too.
|
||||
* There you go, is only a test program. Not made to be fast, small
|
||||
* easy to mantain, or portable. Lots of duplicated code too.
|
||||
|
||||
* I'm not erasing text because I don't want to use other functions from th API
|
||||
* or make this more complex.
|
||||
|
||||
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
|
||||
* by Waldo Alvarez Cañizares <wac at ghost.matcom.uh.cu>, June 22, 2003. */
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define CREATEWINDOW 106
|
||||
#define CREATEWINDOWEX 107
|
||||
#define CREATEWINDOWW 108
|
||||
|
||||
#define ResultX 0
|
||||
#define ResultY 305
|
||||
|
||||
#define NOTIFYX 350
|
||||
#define NOTIFYY 285
|
||||
|
||||
#define BUFFERLEN 80 /* Size of buffer to hold result strings */
|
||||
|
||||
/* Edit is created with this text */
|
||||
#define TestStr "The quick brown fox jumps over the lazy dog"
|
||||
|
||||
#define TestStrW L"This is a WCHAR string" /* Wide to support unicode edits */
|
||||
|
||||
#define MAXMESSAGEBUTTONS 42
|
||||
|
||||
HWND g_hwnd = NULL;
|
||||
HINSTANCE g_hInst = NULL;
|
||||
|
||||
int pos = 10;
|
||||
int n = 0;
|
||||
int yButPos = 10;
|
||||
int xButPos = 10;
|
||||
|
||||
DWORD EditStyle = 0;
|
||||
DWORD EditWidth = 240;
|
||||
DWORD EditHeight = 250;
|
||||
|
||||
BOOL UnicodeUsed = FALSE;
|
||||
|
||||
HWND hwndEdit = NULL;
|
||||
|
||||
POINTL point={10,3};
|
||||
RECT rect = {0,0,20,20},rect2;
|
||||
DWORD StartP,EndP;
|
||||
|
||||
#define ReplaceTextStr "->> Replaced!! <<-"
|
||||
|
||||
char* AllocatedText; /* Buffer in the heap to feed it to the edit control */
|
||||
char* NewText = "New text for the edit control";
|
||||
wchar_t* NewTextW = L"New text for the edit control in UNICODE"; // Wide
|
||||
|
||||
char TextBuffer[BUFFERLEN]={'R','e','s','u','l','t',':',' '};
|
||||
|
||||
typedef void FunctionHandler(HWND,DWORD,WPARAM,LPARAM);
|
||||
typedef FunctionHandler* LPFUNCTIONHANDLER;
|
||||
|
||||
VOID
|
||||
PrintTextXY(char* Text,int x,int y,int len)
|
||||
{
|
||||
HDC hdc;
|
||||
hdc = GetDC (g_hwnd);
|
||||
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
|
||||
|
||||
TextOut (hdc, x,y,Text,len);
|
||||
ReleaseDC (g_hwnd, hdc);
|
||||
ValidateRect (g_hwnd, &rect);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
HandlePrintReturnHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
int ret;
|
||||
ret = SendMessage(handle,Msg,wParam,lParam);
|
||||
htoa(ret,&TextBuffer[8]);
|
||||
PrintTextXY(TextBuffer,ResultX,ResultY,16);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
HandleSetHandlePrintHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
LPVOID pMem;
|
||||
HANDLE hNewBuffer;
|
||||
int ret;
|
||||
|
||||
LocalFree((HLOCAL)SendMessage(handle, EM_GETHANDLE, 0, 0L));
|
||||
if (UnicodeUsed)
|
||||
{
|
||||
hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, 100);
|
||||
pMem = LocalLock(hNewBuffer);
|
||||
strcpyw_((wchar_t*)pMem,NewTextW);
|
||||
}
|
||||
else
|
||||
{
|
||||
hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,50);
|
||||
pMem = LocalLock(hNewBuffer);
|
||||
strcpy_((char*)pMem,NewText);
|
||||
}
|
||||
|
||||
LocalUnlock(pMem);
|
||||
hNewBuffer = LocalHandle(pMem);
|
||||
|
||||
/* Updates the buffer and displays new buffer */
|
||||
ret = SendMessage(handle, EM_SETHANDLE, (WPARAM)hNewBuffer, 0L);
|
||||
|
||||
htoa(ret,&TextBuffer[8]);
|
||||
PrintTextXY(TextBuffer,ResultX,ResultY,16);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
HandlePrintReturnStr(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
int ret;
|
||||
TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */
|
||||
ret = SendMessage(handle,Msg,wParam,lParam);
|
||||
PrintTextXY(TextBuffer,ResultX,ResultY,8+ret);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
HandlePrintRect(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */
|
||||
SendMessage(handle,Msg,wParam,lParam);
|
||||
|
||||
htoa(rect.top,&TextBuffer[8]);
|
||||
TextBuffer[8+8] = ' ';
|
||||
htoa(rect.bottom,&TextBuffer[8+8+1]);
|
||||
TextBuffer[8+8+8+1] = ' ';
|
||||
htoa(rect.left,&TextBuffer[8+8+8+1+1]);
|
||||
TextBuffer[8+8+8+8+1+1] = ' ';
|
||||
htoa(rect.right,&TextBuffer[8+8+8+8+1+1+1]);
|
||||
|
||||
PrintTextXY(TextBuffer,ResultX,ResultY,8+4*9-1);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
HandlePrintPasswdChar(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
int ret = SendMessage(handle,Msg,wParam,lParam);
|
||||
|
||||
int s;
|
||||
|
||||
if (ret)
|
||||
{
|
||||
s = 1;
|
||||
TextBuffer[8] = (char)(ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextBuffer[8] = 'N';
|
||||
TextBuffer[9] = 'U';
|
||||
TextBuffer[10] = 'L';
|
||||
TextBuffer[11] = 'L';
|
||||
s = 4;
|
||||
}
|
||||
|
||||
hdc = GetDC (g_hwnd);
|
||||
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
|
||||
|
||||
TextOut (hdc,ResultX ,ResultY,TextBuffer,8+s);
|
||||
ReleaseDC (g_hwnd, hdc);
|
||||
ValidateRect (g_hwnd, &rect);
|
||||
}
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
char* Text; /* Text for the button */
|
||||
DWORD MsgCode; /* Message Code */
|
||||
WPARAM wParam; /* Well hope you can understand this */
|
||||
LPARAM lParam; /* ditto */
|
||||
LPFUNCTIONHANDLER Handler; /* Funtion called to handle the result of each message */
|
||||
}
|
||||
Msg[] =
|
||||
{
|
||||
{"EM_CANUNDO",EM_CANUNDO,0,0,&HandlePrintReturnHex},
|
||||
{"EM_CHARFROMPOS",EM_CHARFROMPOS,(WPARAM)&point,0,&HandlePrintReturnHex},
|
||||
{"EM_EMPTYUNDOBUFFER",EM_EMPTYUNDOBUFFER,0,0,&HandlePrintReturnHex},
|
||||
{"EM_FMTLINES",EM_FMTLINES,TRUE,0,&HandlePrintReturnHex},
|
||||
{"EM_GETFIRSTVISIBLELINE",EM_GETFIRSTVISIBLELINE,0,0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_GETLIMITTEXT",EM_GETLIMITTEXT,0,0,&HandlePrintReturnHex},
|
||||
{"EM_GETLINE",EM_GETLINE,2,(WPARAM)&TextBuffer[8],&HandlePrintReturnStr},
|
||||
{"EM_GETLINECOUNT",EM_GETLINECOUNT,0,0,&HandlePrintReturnHex},
|
||||
{"EM_GETMARGINS",EM_GETMARGINS,0,0,&HandlePrintReturnHex},
|
||||
{"EM_SETMARGINS",EM_SETMARGINS,EC_LEFTMARGIN,10,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_GETMODIFY",EM_GETMODIFY,0,0,&HandlePrintReturnHex},
|
||||
{"EM_SETMODIFY",EM_SETMODIFY,TRUE,0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_GETSEL",EM_GETSEL,(WPARAM)&StartP,(LPARAM)&EndP,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_GETTHUMB",EM_GETTHUMB,0,0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_LIMITTEXT",EM_LIMITTEXT,10,0,&HandlePrintReturnHex},
|
||||
{"EM_LINEFROMCHAR",EM_LINEFROMCHAR,-1,0,&HandlePrintReturnHex},
|
||||
{"EM_POSFROMCHAR",EM_POSFROMCHAR,10,0,&HandlePrintReturnHex},
|
||||
{"EM_LINEINDEX",EM_LINEINDEX,2,0,&HandlePrintReturnHex},
|
||||
{"EM_LINELENGTH",EM_LINELENGTH,-1,0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_GETWORDBREAKPROC",EM_GETWORDBREAKPROC,0,0,&HandlePrintReturnHex},
|
||||
{"EM_REPLACESEL",EM_REPLACESEL,TRUE,(LPARAM)&ReplaceTextStr,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_LINESCROLL",EM_LINESCROLL,5,1,&HandlePrintReturnHex},
|
||||
{"EM_SCROLL",EM_SCROLL,SB_LINEDOWN,0,&HandlePrintReturnHex},
|
||||
{"EM_SCROLLCARET",EM_SCROLLCARET,0,0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_SETHANDLE",EM_SETHANDLE,0,0,&HandleSetHandlePrintHex},
|
||||
{"EM_GETHANDLE",EM_GETHANDLE,0,0,&HandlePrintReturnHex},
|
||||
{"EM_GETPASSWORDCHAR",EM_GETPASSWORDCHAR,0,0,&HandlePrintPasswdChar},
|
||||
{"EM_SETPASSWORDCHAR - clear",EM_SETPASSWORDCHAR,0,0,&HandlePrintReturnHex},
|
||||
{"EM_SETPASSWORDCHAR - x",EM_SETPASSWORDCHAR,'x',0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_SETREADONLY - set",EM_SETREADONLY,TRUE,0,&HandlePrintReturnHex},
|
||||
{"EM_SETREADONLY - clear",EM_SETREADONLY,FALSE,0,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_GETRECT",EM_GETRECT,0,(LPARAM)&rect2,&HandlePrintRect},
|
||||
{"EM_SETRECT",EM_SETRECT,0,(LPARAM)&rect,&HandlePrintReturnHex},
|
||||
{"EM_SETRECTNP",EM_SETRECTNP,0,(LPARAM)&rect,&HandlePrintReturnHex},
|
||||
{"EM_SETSEL",EM_SETSEL,1,3,&HandlePrintReturnHex},
|
||||
|
||||
{"EM_SETSEL - all",EM_SETSEL,0,-1,&HandlePrintReturnHex},
|
||||
{"EM_SETSEL - remove",EM_SETSEL,-1,0,&HandlePrintReturnHex},
|
||||
{"EM_UNDO",EM_UNDO,0,0,&HandlePrintReturnHex},
|
||||
{"WM_UNDO",WM_UNDO,0,0,&HandlePrintReturnHex},
|
||||
{"WM_PASTE",WM_PASTE,0,0,&HandlePrintReturnHex},
|
||||
|
||||
{"WM_CUT",WM_CUT,0,0,&HandlePrintReturnHex},
|
||||
{"WM_COPY",WM_COPY,0,0,&HandlePrintReturnHex}
|
||||
|
||||
};
|
||||
|
||||
DWORD EditStyles[] = {
|
||||
WS_THICKFRAME,WS_DISABLED,WS_BORDER,ES_LOWERCASE,ES_UPPERCASE,ES_NUMBER,ES_AUTOVSCROLL,
|
||||
ES_AUTOHSCROLL,ES_LEFT,ES_CENTER,ES_RIGHT,ES_MULTILINE,
|
||||
ES_NOHIDESEL,ES_OEMCONVERT,ES_PASSWORD,ES_READONLY,ES_WANTRETURN,
|
||||
WS_HSCROLL,WS_VSCROLL
|
||||
};
|
||||
|
||||
char* StyleNames[] = {
|
||||
"WS_THICKFRAME","WS_DISABLED","WS_BORDER","ES_LOWERCASE","ES_UPPERCASE","ES_NUMBER","ES_AUTOVSCROLL",
|
||||
"ES_AUTOHSCROLL","ES_LEFT","ES_CENTER","ES_RIGHT","ES_MULTILINE",
|
||||
"ES_NOHIDESEL","ES_OEMCONVERT","ES_PASSWORD","ES_READONLY","ES_WANTRETURN",
|
||||
"WS_HSCROLL","WS_VSCROLL"
|
||||
};
|
||||
|
||||
#define NUMBERBUTTONS 26
|
||||
HWND Buttons[NUMBERBUTTONS];
|
||||
HWND MessageButtons[MAXMESSAGEBUTTONS];
|
||||
HWND Back1But,Back2But;
|
||||
HWND NextBut;
|
||||
|
||||
|
||||
HWND
|
||||
CreateCheckButton(const char* lpWindowName, DWORD xSize, DWORD id)
|
||||
{
|
||||
HWND h;
|
||||
h = CreateWindowEx(0,
|
||||
"BUTTON",
|
||||
lpWindowName,
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
|
||||
xButPos, /* x */
|
||||
yButPos, /* y */
|
||||
xSize, /* nWidth */
|
||||
20, /* nHeight */
|
||||
g_hwnd,
|
||||
(HMENU) id,
|
||||
g_hInst,
|
||||
NULL
|
||||
);
|
||||
yButPos += 21;
|
||||
return h;
|
||||
}
|
||||
|
||||
HWND
|
||||
CreatePushButton(const char* lpWindowName, DWORD xSize, DWORD id,DWORD Style)
|
||||
{
|
||||
|
||||
HWND h = CreateWindow("BUTTON",
|
||||
lpWindowName,
|
||||
WS_CHILD | BS_PUSHBUTTON | Style,
|
||||
xButPos, // x
|
||||
yButPos, // y
|
||||
xSize, // nWidth
|
||||
20, // nHeight
|
||||
g_hwnd,
|
||||
(HMENU) id,
|
||||
g_hInst,
|
||||
NULL
|
||||
);
|
||||
|
||||
yButPos += 21;
|
||||
return h;
|
||||
}
|
||||
|
||||
VOID
|
||||
ReadNHide()
|
||||
{
|
||||
int i;
|
||||
EditStyle = 0;
|
||||
for (i=0 ; i< 19 ; i++)
|
||||
{
|
||||
if(BST_CHECKED == SendMessage(Buttons[i],BM_GETCHECK,0,0))
|
||||
EditStyle |= EditStyles[i];
|
||||
ShowWindow(Buttons[i],SW_HIDE);
|
||||
}
|
||||
|
||||
for (; i< NUMBERBUTTONS ; i++)ShowWindow(Buttons[i],SW_HIDE);
|
||||
for (i=0 ; i< 26 ; i++) ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
|
||||
ShowWindow(Back1But,SW_SHOW);
|
||||
ShowWindow(NextBut,SW_SHOW);
|
||||
}
|
||||
|
||||
VOID
|
||||
ForwardToSecondPage()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
for(;i<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
ShowWindow(Back2But,SW_SHOW);
|
||||
|
||||
ShowWindow(Back1But,SW_HIDE);
|
||||
ShowWindow(NextBut,SW_HIDE);
|
||||
}
|
||||
|
||||
VOID
|
||||
BackToFirstPage()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
for(;i<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
ShowWindow(Back2But,SW_HIDE);
|
||||
ShowWindow(Back1But,SW_SHOW);
|
||||
ShowWindow(NextBut,SW_SHOW);
|
||||
}
|
||||
|
||||
VOID
|
||||
BackToInitialPage()
|
||||
{
|
||||
int i;
|
||||
DestroyWindow(hwndEdit);
|
||||
for (i=0 ; i< NUMBERBUTTONS ; i++) {ShowWindow(Buttons[i],SW_SHOW);}
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
ShowWindow(Back1But,SW_HIDE);
|
||||
ShowWindow(NextBut,SW_HIDE);
|
||||
}
|
||||
|
||||
LRESULT
|
||||
CALLBACK
|
||||
WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
int i;
|
||||
switch ( msg )
|
||||
{
|
||||
case WM_CREATE:
|
||||
g_hwnd = hwnd;
|
||||
|
||||
/* ---- Initial page ---- */
|
||||
|
||||
for (i = 0 ; i < 14 ; i++)
|
||||
Buttons[i] = CreateCheckButton(StyleNames[i],150,500+i);
|
||||
|
||||
xButPos += 160;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < 19 ; i++)
|
||||
Buttons[i] = CreateCheckButton(StyleNames[i],140,500+i);
|
||||
|
||||
Buttons[i++] = CreatePushButton("Width +",70,100,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("Width -",70,101,WS_VISIBLE);
|
||||
|
||||
Buttons[i++] = CreatePushButton("Heigth +",70,102,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("Heigth -",70,103,WS_VISIBLE);
|
||||
|
||||
Buttons[i++] = CreatePushButton("CreateWindowA",140,CREATEWINDOW,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("CreateWindowExA",140,CREATEWINDOWEX,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("CreateWindowExW",140,CREATEWINDOWW,WS_VISIBLE);
|
||||
|
||||
|
||||
/* ---- The 1st page of buttons ---- */
|
||||
|
||||
xButPos = 0;
|
||||
yButPos = 10;
|
||||
|
||||
for (i = 0 ; i < 14 ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
xButPos += 180;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < 26 ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
Back1But = CreatePushButton("Back - destroys edit",170,400,0);
|
||||
NextBut = CreatePushButton("Next",170,401,0);
|
||||
|
||||
/* ---- The 2nd page of buttons ------*/
|
||||
|
||||
xButPos = 0;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i<40; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
xButPos += 180;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < MAXMESSAGEBUTTONS ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
Back2But = CreatePushButton("Back",170,402,0);
|
||||
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) >= 600)
|
||||
{
|
||||
Msg[LOWORD(wParam)-600].Handler(hwndEdit,
|
||||
Msg[LOWORD(wParam)-600].MsgCode,
|
||||
Msg[LOWORD(wParam)-600].wParam,
|
||||
Msg[LOWORD(wParam)-600].lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(LOWORD(wParam)){
|
||||
|
||||
case 100:
|
||||
EditWidth += 10;
|
||||
break;
|
||||
|
||||
case 101:
|
||||
EditWidth -= 10;
|
||||
break;
|
||||
|
||||
case 102:
|
||||
EditHeight += 10;
|
||||
break;
|
||||
|
||||
case 103:
|
||||
EditHeight -= 10;
|
||||
break;
|
||||
|
||||
case 400:
|
||||
BackToInitialPage();
|
||||
break;
|
||||
|
||||
case 401:
|
||||
ForwardToSecondPage();
|
||||
break;
|
||||
|
||||
case 402:
|
||||
BackToFirstPage();
|
||||
break;
|
||||
|
||||
case CREATEWINDOW:
|
||||
UnicodeUsed = FALSE;
|
||||
ReadNHide();
|
||||
hwndEdit = CreateWindow("EDIT",
|
||||
TestStr,
|
||||
EditStyle | WS_CHILD | WS_VISIBLE,
|
||||
350,
|
||||
10,
|
||||
EditWidth,
|
||||
EditHeight,
|
||||
g_hwnd,
|
||||
NULL,
|
||||
g_hInst,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
case CREATEWINDOWEX:
|
||||
UnicodeUsed = FALSE;
|
||||
ReadNHide();
|
||||
hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
|
||||
"EDIT",
|
||||
TestStr,
|
||||
EditStyle | WS_CHILD | WS_VISIBLE ,
|
||||
350,
|
||||
10,
|
||||
EditWidth,
|
||||
EditHeight,
|
||||
g_hwnd,
|
||||
NULL,
|
||||
g_hInst,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
case CREATEWINDOWW:
|
||||
UnicodeUsed = TRUE;
|
||||
ReadNHide();
|
||||
hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE,
|
||||
L"EDIT",
|
||||
TestStrW,
|
||||
EditStyle | WS_CHILD | WS_VISIBLE ,
|
||||
350,
|
||||
10,
|
||||
EditWidth,
|
||||
EditHeight,
|
||||
g_hwnd,
|
||||
NULL,
|
||||
g_hInst,
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (lParam == (LPARAM)hwndEdit)
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case EN_CHANGE:
|
||||
PrintTextXY("EN_CHANGE notification",NOTIFYX,NOTIFYY,22);
|
||||
break;
|
||||
|
||||
case EN_ERRSPACE:
|
||||
PrintTextXY("EN_ERRSPACE notification",NOTIFYX,NOTIFYY,24);
|
||||
break;
|
||||
|
||||
/* --- FIXME not defined in w32api-2.3 headers
|
||||
case H_SCROLL:
|
||||
PrintTextXY("H_SCROLL notification",NOTIFYX,NOTIFYY,21);
|
||||
break; */
|
||||
|
||||
/* --- FIXME not defined in w32api-2.3 headers
|
||||
case KILL_FOCUS:
|
||||
PrintTextXY("KILL_FOCUS notification",NOTIFYX,NOTIFYY,23);
|
||||
break; */
|
||||
|
||||
/* --- FIXME not defined in w32api-2.3 headers
|
||||
case EN_MAXTEST:
|
||||
PrintTextXY("EN_MAXTEXT notification",NOTIFYX,NOTIFYY,23);
|
||||
break; */
|
||||
|
||||
case EN_SETFOCUS:
|
||||
PrintTextXY("EN_SETFOCUS notification",NOTIFYX,NOTIFYY,24);
|
||||
break;
|
||||
|
||||
case EN_UPDATE:
|
||||
PrintTextXY("EN_UPDATE notification",NOTIFYX,NOTIFYY + 20,22);
|
||||
break;
|
||||
|
||||
case EN_VSCROLL:
|
||||
PrintTextXY("EN_VSCROLL notification",NOTIFYX,NOTIFYY,23);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WM_SIZE :
|
||||
return 0;
|
||||
|
||||
case WM_CLOSE:
|
||||
DestroyWindow (g_hwnd);
|
||||
return 0;
|
||||
|
||||
case WM_QUERYENDSESSION:
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProc ( hwnd, msg, wParam, lParam );
|
||||
}
|
||||
|
||||
HWND
|
||||
RegisterAndCreateWindow (HINSTANCE hInst,
|
||||
const char* className,
|
||||
const char* title)
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
HWND hwnd;
|
||||
|
||||
g_hInst = hInst;
|
||||
|
||||
wc.cbSize = sizeof (WNDCLASSEX);
|
||||
|
||||
wc.lpfnWndProc = WndProc; /* window procedure */
|
||||
wc.hInstance = hInst; /* owner of the class */
|
||||
|
||||
wc.lpszClassName = className;
|
||||
wc.hCursor = LoadCursor ( 0, (LPCTSTR)IDC_ARROW );
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hIcon = 0;
|
||||
wc.hIconSm = 0;
|
||||
wc.lpszMenuName = 0;
|
||||
|
||||
if ( !RegisterClassEx ( &wc ) )
|
||||
return NULL;
|
||||
|
||||
hwnd = CreateWindowEx (
|
||||
0, /* dwStyleEx */
|
||||
className, /* class name */
|
||||
title, /* window title */
|
||||
|
||||
WS_OVERLAPPEDWINDOW, /* dwStyle */
|
||||
|
||||
1, /* x */
|
||||
1, /* y */
|
||||
560, /* width */
|
||||
350, /* height */
|
||||
NULL, /* hwndParent */
|
||||
NULL, /* hMenu */
|
||||
hInst,
|
||||
0
|
||||
);
|
||||
|
||||
if (!hwnd) return NULL;
|
||||
|
||||
ShowWindow (hwnd, SW_SHOW);
|
||||
UpdateWindow (hwnd);
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
int
|
||||
WINAPI
|
||||
WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow )
|
||||
{
|
||||
char className [] = "Edit Control Test";
|
||||
MSG msg;
|
||||
|
||||
RegisterAndCreateWindow ( hInst, className, "Edit Control Styles Test" );
|
||||
|
||||
// Message loop
|
||||
while (GetMessage (&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
return msg.wParam;
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = edittest
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a gdi32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
edittest.o \
|
||||
utils.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Edit Control Test for ReactOS, quick n' dirty. There you go
|
||||
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
|
||||
* by Waldo Alvarez Cañizares <wac at ghost.matcom.uh.cu>, June 22, 2003.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static const char hexvals[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
VOID htoa (unsigned int val, char *buf)
|
||||
{
|
||||
int i;
|
||||
buf += 7;
|
||||
|
||||
for (i=0;i<8;i++)
|
||||
{
|
||||
*buf-- = hexvals[val & 0x0000000F];
|
||||
val = val >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID strcpy_(char *dst, const char *src)
|
||||
{
|
||||
const char* p = src;
|
||||
while ((*dst++ = *p++)) {}
|
||||
}
|
||||
|
||||
VOID strcpyw_(wchar_t* dst,wchar_t* src)
|
||||
{
|
||||
const wchar_t* p = src;
|
||||
while ((*dst++ = *p++)) {}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
VOID htoa (unsigned int, char *);
|
||||
VOID strcpy_(char *, const char *);
|
||||
VOID strcpyw_(wchar_t*,wchar_t*);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,123 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
//HFONT tf;
|
||||
HENHMETAFILE EnhMetafile;
|
||||
SIZE EnhMetafileSize;
|
||||
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
MSG msg;
|
||||
HWND hWnd;
|
||||
ENHMETAHEADER emh;
|
||||
|
||||
EnhMetafile = GetEnhMetaFile("test.emf");
|
||||
if(!EnhMetafile)
|
||||
{
|
||||
fprintf(stderr, "GetEnhMetaFile failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
GetEnhMetaFileHeader(EnhMetafile, sizeof(ENHMETAHEADER), &emh);
|
||||
EnhMetafileSize.cx = emh.rclBounds.right - emh.rclBounds.left;
|
||||
EnhMetafileSize.cy = emh.rclBounds.bottom - emh.rclBounds.top;
|
||||
|
||||
wc.lpszClassName = "EnhMetaFileClass";
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
if (RegisterClass(&wc) == 0)
|
||||
{
|
||||
DeleteEnhMetaFile(EnhMetafile);
|
||||
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
hWnd = CreateWindow("EnhMetaFileClass",
|
||||
"Enhanced Metafile test",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0,
|
||||
0,
|
||||
EnhMetafileSize.cx + (2 * GetSystemMetrics(SM_CXSIZEFRAME)) + 2,
|
||||
EnhMetafileSize.cy + (2 * GetSystemMetrics(SM_CYSIZEFRAME)) + GetSystemMetrics(SM_CYCAPTION) + 2,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
DeleteEnhMetaFile(EnhMetafile);
|
||||
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
DeleteEnhMetaFile(EnhMetafile);
|
||||
|
||||
//DeleteObject(tf);
|
||||
UnregisterClass("EnhMetaFileClass", hInstance);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
RECT rc;
|
||||
HDC hDC;
|
||||
int bk;
|
||||
|
||||
GetClientRect(hWnd, &rc);
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
rc.left = (rc.right / 2) - (EnhMetafileSize.cx / 2);
|
||||
rc.top = (rc.bottom / 2) - (EnhMetafileSize.cy / 2);
|
||||
rc.right = rc.left + EnhMetafileSize.cx;
|
||||
rc.bottom = rc.top + EnhMetafileSize.cy;
|
||||
bk = SetBkMode(hDC, TRANSPARENT);
|
||||
Rectangle(hDC, rc.left - 1, rc.top - 1, rc.right + 1, rc.bottom + 1);
|
||||
SetBkMode(hDC, bk);
|
||||
PlayEnhMetaFile(hDC, EnhMetafile, &rc);
|
||||
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.1 2003/11/15 14:05:30 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = enhmetafile
|
||||
|
||||
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
|
Binary file not shown.
|
@ -1,271 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 4 - Listing 4.2 (Font Enumeration 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>
|
||||
|
||||
|
||||
#ifndef SNDMSG
|
||||
#define SNDMSG ::SendMessage
|
||||
#endif /* ifndef SNDMSG */
|
||||
|
||||
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
HWND hListBox = NULL;
|
||||
const int ID_LISTBOX = 101;
|
||||
|
||||
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 = NULL; //LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = reinterpret_cast<HBRUSH>(
|
||||
COLOR_BTNFACE + 1
|
||||
);
|
||||
|
||||
if (RegisterClass(&wc))
|
||||
{
|
||||
HWND hWnd =
|
||||
CreateWindow(
|
||||
WndClassName, TEXT("Font Enumeration Demo"),
|
||||
WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
|
||||
WS_VISIBLE | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 295, 285,
|
||||
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;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
int CALLBACK MyEnumFontFamExProc(ENUMLOGFONTEX *lpelfe,
|
||||
NEWTEXTMETRICEX* lpntme, int FontType, LPARAM lParam)
|
||||
{
|
||||
if (FontType == TRUETYPE_FONTTYPE)
|
||||
{
|
||||
// if the typeface name is not already in the list
|
||||
LPARAM name = reinterpret_cast<LPARAM>(lpelfe->elfFullName);
|
||||
if (SNDMSG(hListBox, LB_FINDSTRINGEXACT, (ULONG)-1, name) == LB_ERR)
|
||||
{
|
||||
// add each font to the list box
|
||||
int index = SNDMSG(hListBox, LB_ADDSTRING, 0, name);
|
||||
|
||||
// fix the size of the font
|
||||
lpelfe->elfLogFont.lfHeight = -20;
|
||||
lpelfe->elfLogFont.lfWidth = 0;
|
||||
|
||||
// create a new font and store its handle
|
||||
// as the data of the newly added item
|
||||
HFONT hFont = CreateFontIndirect(&lpelfe->elfLogFont);
|
||||
SNDMSG(hListBox, LB_SETITEMDATA, index,
|
||||
reinterpret_cast<LPARAM>(hFont));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
void AddScreenFonts()
|
||||
{
|
||||
// grab a handle to the screen's DC
|
||||
HDC hScreenDC = GetDC(NULL);
|
||||
try
|
||||
{
|
||||
//
|
||||
// NOTE: Windows 95, 98 and Me requires that the lpLogfont
|
||||
// (second) parameter of the EnumFontFamiliesEx function is
|
||||
// non-NULL. This parameter can be NULL on Windows NT/2000.
|
||||
//
|
||||
LOGFONT lf = {0};
|
||||
lf.lfCharSet = DEFAULT_CHARSET;
|
||||
|
||||
// enumerate the current screen fonts
|
||||
EnumFontFamiliesEx(
|
||||
hScreenDC, &lf,
|
||||
(FONTENUMPROC)MyEnumFontFamExProc,
|
||||
0, 0
|
||||
);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// release the screen's DC
|
||||
ReleaseDC(NULL, hScreenDC);
|
||||
}
|
||||
// release the screen's DC
|
||||
ReleaseDC(NULL, hScreenDC);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
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 | LBS_STANDARD |
|
||||
LBS_HASSTRINGS | LBS_OWNERDRAWFIXED,
|
||||
20, 10, 250, 250,
|
||||
hWnd, reinterpret_cast<HMENU>(ID_LISTBOX),
|
||||
hInst, NULL
|
||||
);
|
||||
if (hListBox)
|
||||
{
|
||||
AddScreenFonts();
|
||||
}
|
||||
}
|
||||
case WM_MEASUREITEM:
|
||||
{
|
||||
// grab a pointer to the MEASUREITEMSTRUCT structure
|
||||
LPMEASUREITEMSTRUCT lpmis =
|
||||
reinterpret_cast<LPMEASUREITEMSTRUCT>(lParam);
|
||||
|
||||
// test the identifier of the control that
|
||||
// the message is meant for
|
||||
if ((int)lpmis->CtlID == ID_LISTBOX)
|
||||
{
|
||||
// adjust the height
|
||||
lpmis->itemHeight = 25;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
// grab a pointer to the DRAWITEMSTRUCT structure
|
||||
LPDRAWITEMSTRUCT lpdis =
|
||||
reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
|
||||
|
||||
// test the identifier of the control that
|
||||
// the message is meant for
|
||||
if ((int)lpdis->CtlID == ID_LISTBOX)
|
||||
{
|
||||
COLORREF OldColor = GetTextColor(lpdis->hDC);
|
||||
int stock = WHITE_BRUSH;
|
||||
|
||||
// if the item is currently selected
|
||||
if (lpdis->itemState & ODS_SELECTED)
|
||||
{
|
||||
// set the text color to white and
|
||||
// the background color to black
|
||||
COLORREF clrWhite = PALETTERGB(255, 255, 255);
|
||||
OldColor = SetTextColor(lpdis->hDC, clrWhite);
|
||||
stock = BLACK_BRUSH;
|
||||
}
|
||||
FillRect(
|
||||
lpdis->hDC, &lpdis->rcItem,
|
||||
static_cast<HBRUSH>(GetStockObject(stock))
|
||||
);
|
||||
|
||||
if ((int)lpdis->itemID != -1)
|
||||
{
|
||||
// extract the item's text
|
||||
char text[MAX_PATH];
|
||||
SNDMSG(hListBox, LB_GETTEXT, lpdis->itemID,
|
||||
reinterpret_cast<LPARAM>(text));
|
||||
|
||||
// extract the corresponding font handle
|
||||
DWORD value =
|
||||
SNDMSG(hListBox, LB_GETITEMDATA, lpdis->itemID, 0);
|
||||
HFONT hFont = reinterpret_cast<HFONT>(value);
|
||||
|
||||
// select the corresponding font
|
||||
// into the device context
|
||||
HFONT HOldFont = static_cast<HFONT>(
|
||||
SelectObject(lpdis->hDC, hFont)
|
||||
);
|
||||
|
||||
// render the text transparently
|
||||
SetBkMode(lpdis->hDC, TRANSPARENT);
|
||||
|
||||
// render the text
|
||||
RECT RText = lpdis->rcItem;
|
||||
InflateRect(&RText, -2, -2);
|
||||
DrawText(lpdis->hDC, text, strlen(text), &RText,
|
||||
DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
||||
|
||||
// restore the previous font
|
||||
SelectObject(lpdis->hDC, HOldFont);
|
||||
}
|
||||
|
||||
// render the focus rectangle
|
||||
if (lpdis->itemState & ODS_FOCUS)
|
||||
{
|
||||
DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
|
||||
}
|
||||
|
||||
// restore the previous color/mode
|
||||
SetTextColor(lpdis->hDC, OldColor);
|
||||
SetBkMode(lpdis->hDC, OPAQUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
// delete each created font object
|
||||
int count = SNDMSG(hListBox, LB_GETCOUNT, 0, 0);
|
||||
for (int index = 0; index < count; ++index)
|
||||
{
|
||||
DWORD value = SNDMSG(hListBox, LB_GETITEMDATA, index, 0);
|
||||
DeleteObject(reinterpret_cast<HFONT>(value));
|
||||
}
|
||||
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = enumfonts
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a gdi32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_GCCLIBS = stdc++
|
||||
|
||||
TARGET_CPPFLAGS = -Wall -Werror -D__USE_W32API -DWIN32 -D_WIN32_IE=0x0600 -D_WIN32_WINNT=0x0501 -fexceptions -Wall -I.
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* enumwnd.c
|
||||
*
|
||||
* application to test the various Window Enumeration functions
|
||||
*/
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HBRUSH hbrBackground;
|
||||
HFONT tf;
|
||||
int test = 0;
|
||||
const TCHAR* APP_NAME = "EnumWnd Test";
|
||||
const TCHAR* CLASS_NAME = "EnumWndTestClass";
|
||||
|
||||
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 = CLASS_NAME;
|
||||
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)
|
||||
{
|
||||
_ftprintf ( stderr, _T("RegisterClass failed (last error 0x%lX)\n"),
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
hWnd = CreateWindow(CLASS_NAME,
|
||||
APP_NAME,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0,
|
||||
0,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
_ftprintf ( stderr, _T("CreateWindow failed (last error 0x%lX)\n"),
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
tf = CreateFont (14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, _T("Timmons"));
|
||||
|
||||
hbrBackground = CreateSolidBrush ( RGB(192,192,192) );
|
||||
|
||||
ShowWindow ( hWnd, nCmdShow );
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
DeleteObject(hbrBackground);
|
||||
|
||||
DeleteObject(tf);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
void MyTextOut ( HDC hdc, int x, int y, const TCHAR* text )
|
||||
{
|
||||
TextOut ( hdc, x, y, text, _tcslen(text) );
|
||||
}
|
||||
|
||||
typedef struct _EnumData
|
||||
{
|
||||
HDC hdc;
|
||||
int x;
|
||||
int y;
|
||||
} EnumData;
|
||||
|
||||
BOOL CALLBACK MyWindowEnumProc ( HWND hwnd, LPARAM lParam )
|
||||
{
|
||||
TCHAR wndcaption[1024], buf[1024];
|
||||
EnumData* ped = (EnumData*)lParam;
|
||||
GetWindowText ( hwnd, wndcaption, sizeof(wndcaption)/sizeof(*wndcaption) );
|
||||
_sntprintf ( buf, sizeof(buf)/sizeof(*buf), _T("%x - %s"), hwnd, wndcaption );
|
||||
MyTextOut ( ped->hdc, ped->x, ped->y, buf );
|
||||
ped->y += 13;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
RECT rect;
|
||||
TCHAR buf[100];
|
||||
EnumData ed;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
SelectObject(hDC, tf);
|
||||
|
||||
GetClientRect ( hWnd, &rect );
|
||||
FillRect ( hDC, &rect, hbrBackground );
|
||||
|
||||
MyTextOut ( hDC, 10, 10, "EnumWnd Test" );
|
||||
|
||||
_sntprintf ( buf, sizeof(buf)/sizeof(*buf), _T("My HWND: %x"), hWnd );
|
||||
MyTextOut ( hDC, 10, 30, buf );
|
||||
|
||||
ed.hdc = hDC;
|
||||
ed.x = 10;
|
||||
ed.y = 70;
|
||||
|
||||
switch ( test )
|
||||
{
|
||||
case 1:
|
||||
MyTextOut ( hDC, 10, 50, _T("Test #1: EnumWindows()") );
|
||||
EnumWindows ( MyWindowEnumProc, (LPARAM)&ed );
|
||||
break;
|
||||
case 2:
|
||||
MyTextOut ( hDC, 10, 50, _T("Test #2: EnumChildWindows()") );
|
||||
EnumChildWindows ( hWnd, MyWindowEnumProc, (LPARAM)&ed );
|
||||
break;
|
||||
case 3:
|
||||
MyTextOut ( hDC, 10, 50, _T("Test #3: EnumDesktopWindows") );
|
||||
EnumDesktopWindows ( NULL, MyWindowEnumProc, (LPARAM)&ed );
|
||||
break;
|
||||
case 4:
|
||||
MyTextOut ( hDC, 10, 50, _T("Test #4: EnumThreadWindows") );
|
||||
EnumThreadWindows ( GetCurrentThreadId(), MyWindowEnumProc, (LPARAM)&ed );
|
||||
break;
|
||||
default:
|
||||
MyTextOut ( hDC, 10, 50, _T("Press any of the number keys from 1 to 4 to run a test") );
|
||||
MyTextOut ( hDC, 10, 70, _T("Press the left and right mouse buttons to cycle through the tests") );
|
||||
break;
|
||||
}
|
||||
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
test = (TCHAR)wParam - '1' + 1;
|
||||
RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE );
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
if ( ++test > 4 )
|
||||
test = 1;
|
||||
RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE );
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
if ( !--test )
|
||||
test = 4;
|
||||
RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE );
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="enumwnd" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=enumwnd - 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 "enumwnd.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 "enumwnd.mak" CFG="enumwnd - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "enumwnd - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "enumwnd - 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)" == "enumwnd - 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)" == "enumwnd - 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 /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 /debug /machine:I386 /pdbtype:sept
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "enumwnd - Win32 Release"
|
||||
# Name "enumwnd - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\enumwnd.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:16 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = enumwnd
|
||||
|
||||
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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,35 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
BOOL CALLBACK
|
||||
EnumDesktopProc(LPWSTR lpszWindowStation, LPARAM lParam)
|
||||
{
|
||||
printf("\t%S\n", lpszWindowStation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
EnumWindowStationProc(LPWSTR lpszWindowStation, LPARAM lParam)
|
||||
{
|
||||
HWINSTA hWinSta;
|
||||
|
||||
printf("%S\n", lpszWindowStation);
|
||||
hWinSta = OpenWindowStationW(lpszWindowStation, FALSE,
|
||||
WINSTA_ENUMDESKTOPS);
|
||||
if (hWinSta == NULL)
|
||||
{
|
||||
printf("\tCan't open window station.\n");
|
||||
return TRUE;
|
||||
}
|
||||
EnumDesktopsW(hWinSta, EnumDesktopProc, 0xdede);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
EnumWindowStationsW(EnumWindowStationProc, 0xbadbed);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = enumws
|
||||
|
||||
TARGET_SDKLIBS = user32.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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,33 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE events[2];
|
||||
|
||||
DWORD WINAPI thread( LPVOID crap )
|
||||
{
|
||||
SetEvent( events[0] );
|
||||
if( crap )
|
||||
SetEvent( events[1] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main( void )
|
||||
{
|
||||
DWORD id, Status;
|
||||
printf( "Creating events\n" );
|
||||
events[0] = CreateEvent( 0, TRUE, FALSE, 0 );
|
||||
events[1] = CreateEvent( 0, TRUE, FALSE, 0 );
|
||||
printf( "Created events\n" );
|
||||
CreateThread( 0, 0, thread, 0, 0, &id );
|
||||
printf( "WaitForSingleObject %s\n", ( WaitForSingleObject( events[0], INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) );
|
||||
ResetEvent( events[0] );
|
||||
CreateThread( 0, 0, thread, 0, 0, &id );
|
||||
printf( "WaitForMultipleObjects with waitall = FALSE %s\n", ( WaitForMultipleObjects( 2, events, FALSE, INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) );
|
||||
ResetEvent( events[0] );
|
||||
CreateThread( 0, 0, thread, (void *)1, 0, &id );
|
||||
Status = WaitForMultipleObjects( 2, events, TRUE, INFINITE );
|
||||
printf( "WaitForMultipleObjects with waitall = TRUE %s\n", ( Status == WAIT_OBJECT_0 || Status == WAIT_OBJECT_0 + 1 ? "worked" : "failed" ) );
|
||||
ResetEvent( events[0] );
|
||||
printf( "WaitForSingleObject with timeout %s\n", ( WaitForSingleObject( events[0], 100 ) == WAIT_TIMEOUT ? "worked" : "failed" ) );
|
||||
return 0;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.8 2003/11/14 17:13:16 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = event
|
||||
|
||||
TARGET_SDKLIBS = kernel32.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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Author: Skywing (skywing@valhallalegends.com)
|
||||
* Date: 09/09/2003
|
||||
* Purpose: Test Thread-EventPair functionality.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#ifndef NTAPI
|
||||
#define NTAPI WINAPI
|
||||
#endif
|
||||
|
||||
HANDLE MakeEventPair()
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE EventPair;
|
||||
OBJECT_ATTRIBUTES Attributes;
|
||||
|
||||
InitializeObjectAttributes(&Attributes, NULL, 0, NULL, NULL);
|
||||
Status = NtCreateEventPair(&EventPair, STANDARD_RIGHTS_ALL, &Attributes);
|
||||
printf("Status %08lx creating eventpair\n", Status);
|
||||
return EventPair;
|
||||
}
|
||||
|
||||
DWORD __stdcall threadfunc(void* eventpair)
|
||||
{
|
||||
printf("Thread: Set eventpair status %08lx\n", NtSetInformationThread(NtCurrentThread(), ThreadEventPair, &eventpair, sizeof(HANDLE)));
|
||||
Sleep(2500);
|
||||
|
||||
printf("Thread: Setting low and waiting high...\n");
|
||||
printf("Thread: status = %08lx\n", NtSetLowWaitHighThread());
|
||||
printf("Thread: status = %08lx\n", NtSetHighWaitLowThread());
|
||||
printf("Thread: Terminating...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
DWORD id;
|
||||
HANDLE EventPair, Thread;
|
||||
|
||||
printf("Main: NtSetLowWaitHighThread is at %08lx\n", NtSetLowWaitHighThread());
|
||||
|
||||
EventPair = MakeEventPair();
|
||||
|
||||
if(!EventPair) {
|
||||
printf("Main: Could not create event pair.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Main: EventPair = %08lx\n", (DWORD)EventPair);
|
||||
Thread = CreateThread(0, 0, threadfunc, EventPair, 0, &id);
|
||||
printf("Main: ThreadId for new thread is %08lx\n", id);
|
||||
printf("Main: Setting high and waiting low\n");
|
||||
printf("Main: status = %08lx\n", NtSetHighWaitLowEventPair(EventPair));
|
||||
Sleep(2500);
|
||||
printf("Main: status = %08lx\n", NtSetLowWaitHighEventPair(EventPair));
|
||||
NtClose(EventPair);
|
||||
/* WaitForSingleObject(Thread, INFINITE); FIXME: Waiting on thread handle causes double spinlock acquisition (and subsequent crash) in PsUnblockThread - ntoskrnl/ps/thread.c */
|
||||
NtClose(Thread);
|
||||
printf("Main: Terminating...\n");
|
||||
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 = console
|
||||
|
||||
TARGET_NAME = eventpair
|
||||
|
||||
TARGET_SDKLIBS = ntdll.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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,21 +0,0 @@
|
|||
# $Id: Makefile,v 1.2 2004/03/07 20:07:04 hyperion Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = fiber
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,446 +0,0 @@
|
|||
/* $Id: fiber.c,v 1.4 2004/07/07 22:29:37 gvg Exp $
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef InitializeListHead
|
||||
#define InitializeListHead(PLH__) ((PLH__)->Flink = (PLH__)->Blink = (PLH__))
|
||||
#endif
|
||||
|
||||
#ifndef IsListEmpty
|
||||
#define IsListEmpty(PLH__) ((PLH__)->Flink == (PVOID)(PLH__))
|
||||
#endif
|
||||
|
||||
#ifndef RemoveEntryList
|
||||
|
||||
#define RemoveEntryList(PLE__) \
|
||||
{ \
|
||||
PLIST_ENTRY pleBack__ = (PLIST_ENTRY)((PLE__)->Blink); \
|
||||
PLIST_ENTRY pleForward__ = (PLIST_ENTRY)((PLE__)->Flink); \
|
||||
\
|
||||
pleBack__->Flink = pleForward__; \
|
||||
pleForward__->Blink = pleBack__; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef InsertTailList
|
||||
|
||||
#define InsertTailList(PLH__, PLE__) \
|
||||
{ \
|
||||
PLIST_ENTRY pleListHead__ = (PLH__); \
|
||||
PLIST_ENTRY pleBlink__ = (PLIST_ENTRY)((PLH__)->Blink); \
|
||||
\
|
||||
(PLE__)->Flink = pleListHead__; \
|
||||
(PLE__)->Blink = pleBlink__; \
|
||||
pleBlink__->Flink = (PLE__); \
|
||||
pleListHead__->Blink = (PLE__); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef RemoveHeadList
|
||||
|
||||
#define RemoveHeadList(PLH__) \
|
||||
(PLIST_ENTRY)((PLH__)->Flink); \
|
||||
RemoveEntryList((PLIST_ENTRY)((PLH__)->Flink));
|
||||
|
||||
#endif
|
||||
|
||||
#define FIBERTEST_COUNT 500
|
||||
|
||||
struct FiberData
|
||||
{
|
||||
unsigned nMagic;
|
||||
unsigned nId;
|
||||
unsigned nPrio;
|
||||
unsigned nRealPrio;
|
||||
PVOID pFiber;
|
||||
LIST_ENTRY leQueue;
|
||||
int nQuantumQueued;
|
||||
int nBoost;
|
||||
struct FiberData * pfdPrev;
|
||||
int bExitPrev;
|
||||
};
|
||||
|
||||
static LIST_ENTRY a_leQueues[32];
|
||||
static unsigned nQuantum = 0;
|
||||
static struct FiberData * pfdLastStarveScan = NULL;
|
||||
|
||||
void Fbt_Create(int);
|
||||
void Fbt_Exit(void);
|
||||
void Fbt_Yield(void);
|
||||
|
||||
struct FiberData * Fbt_GetCurrent(void);
|
||||
unsigned Fbt_GetCurrentId(void);
|
||||
VOID CALLBACK Fbt_Startup(PVOID);
|
||||
void Fbt_Dispatch(struct FiberData *, int);
|
||||
void Fbt_AfterSwitch(struct FiberData *);
|
||||
|
||||
void DoStuff(void);
|
||||
|
||||
struct FiberData * Fbt_GetCurrent(VOID)
|
||||
{
|
||||
return GetFiberData();
|
||||
}
|
||||
|
||||
unsigned Fbt_GetCurrentId(VOID)
|
||||
{
|
||||
return Fbt_GetCurrent()->nId;
|
||||
}
|
||||
|
||||
void Fbt_Yield(VOID)
|
||||
{
|
||||
struct FiberData * pfdCur;
|
||||
|
||||
pfdCur = Fbt_GetCurrent();
|
||||
|
||||
if(pfdCur->nBoost)
|
||||
{
|
||||
-- pfdCur->nBoost;
|
||||
|
||||
if(!pfdCur->nBoost)
|
||||
pfdCur->nPrio = pfdCur->nRealPrio;
|
||||
}
|
||||
else if((rand() % 100) > 50 - (45 * pfdCur->nPrio) / 32)
|
||||
Fbt_Dispatch(pfdCur, 0);
|
||||
}
|
||||
|
||||
void Fbt_AfterSwitch(struct FiberData * pfdCur)
|
||||
{
|
||||
struct FiberData * pfdPrev;
|
||||
|
||||
pfdPrev = pfdCur->pfdPrev;
|
||||
|
||||
/* The previous fiber left some homework for us */
|
||||
if(pfdPrev)
|
||||
{
|
||||
/* Kill the predecessor */
|
||||
if(pfdCur->bExitPrev)
|
||||
{
|
||||
if(pfdLastStarveScan == pfdPrev)
|
||||
pfdLastStarveScan = 0;
|
||||
|
||||
DeleteFiber(pfdPrev->pFiber);
|
||||
free(pfdPrev);
|
||||
}
|
||||
/* Enqueue the previous fiber in the correct ready queue */
|
||||
else
|
||||
{
|
||||
/* Remember the quantum in which the previous fiber was queued */
|
||||
pfdPrev->nQuantumQueued = nQuantum;
|
||||
|
||||
/* Disable the anti-starvation boost */
|
||||
if(pfdPrev->nBoost)
|
||||
{
|
||||
pfdPrev->nBoost = 0;
|
||||
pfdPrev->nPrio = pfdPrev->nRealPrio;
|
||||
}
|
||||
|
||||
/* Enqueue the previous fiber */
|
||||
InsertTailList
|
||||
(
|
||||
&a_leQueues[pfdPrev->nPrio],
|
||||
&pfdPrev->leQueue
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID CALLBACK Fbt_Startup(PVOID pParam)
|
||||
{
|
||||
assert(pParam == GetFiberData());
|
||||
Fbt_AfterSwitch(pParam);
|
||||
DoStuff();
|
||||
Fbt_Exit();
|
||||
}
|
||||
|
||||
void Fbt_Dispatch(struct FiberData * pfdCur, int bExit)
|
||||
{
|
||||
UCHAR i;
|
||||
UCHAR n;
|
||||
struct FiberData * pfdNext;
|
||||
|
||||
assert(pfdCur == GetFiberData());
|
||||
|
||||
++ nQuantum;
|
||||
|
||||
/* Every ten quantums check for starving threads */
|
||||
/* FIXME: this implementation of starvation prevention isn't that great */
|
||||
if(nQuantum % 10 == 0)
|
||||
{
|
||||
int j;
|
||||
int k;
|
||||
int b;
|
||||
int bResume;
|
||||
PLIST_ENTRY ple = NULL;
|
||||
|
||||
bResume = 0;
|
||||
i = 0;
|
||||
|
||||
/* Pick up from where we left last time */
|
||||
if(pfdLastStarveScan)
|
||||
{
|
||||
unsigned nPrio;
|
||||
|
||||
nPrio = pfdLastStarveScan->nPrio;
|
||||
|
||||
/* The last fiber we scanned for starvation isn't queued anymore */
|
||||
if(IsListEmpty(&pfdLastStarveScan->leQueue))
|
||||
/* Scan the ready queue for its priority */
|
||||
i = nPrio;
|
||||
/* Last fiber for its priority level */
|
||||
else if(pfdLastStarveScan->leQueue.Flink == &a_leQueues[nPrio])
|
||||
/* Scan the ready queue for the next priority level */
|
||||
i = nPrio + 1;
|
||||
/* Scan the next fiber in the ready queue */
|
||||
else
|
||||
{
|
||||
i = nPrio;
|
||||
ple = pfdLastStarveScan->leQueue.Flink;
|
||||
bResume = 1;
|
||||
}
|
||||
|
||||
/* Priority levels 15-31 are never checked for starvation */
|
||||
if(i >= 15)
|
||||
{
|
||||
if(bResume)
|
||||
bResume = 0;
|
||||
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Scan at most 16 threads, in the priority range 0-14, applying in total at
|
||||
most 10 boosts. This loop scales O(1)
|
||||
*/
|
||||
for(j = 0, k = 0, b = 0; j < 16 && k < 15 && b < 10; ++ j)
|
||||
{
|
||||
unsigned nDiff;
|
||||
|
||||
/* No previous state to resume from */
|
||||
if(!bResume)
|
||||
{
|
||||
int nQueue;
|
||||
|
||||
/* Get the first element in the current queue */
|
||||
nQueue = (k + i) % 15;
|
||||
|
||||
if(IsListEmpty(&a_leQueues[nQueue]))
|
||||
{
|
||||
++ k;
|
||||
continue;
|
||||
}
|
||||
|
||||
ple = (PLIST_ENTRY)a_leQueues[nQueue].Flink;
|
||||
}
|
||||
else
|
||||
bResume = 0;
|
||||
|
||||
/* Get the current fiber */
|
||||
pfdLastStarveScan = CONTAINING_RECORD(ple, struct FiberData, leQueue);
|
||||
assert(pfdLastStarveScan->nMagic == 0x12345678);
|
||||
assert(pfdLastStarveScan != pfdCur);
|
||||
|
||||
/* Calculate the number of quantums the fiber has been in the queue */
|
||||
if(nQuantum > pfdLastStarveScan->nQuantumQueued)
|
||||
nDiff = nQuantum - pfdLastStarveScan->nQuantumQueued;
|
||||
else
|
||||
nDiff = UINT_MAX - pfdLastStarveScan->nQuantumQueued + nQuantum;
|
||||
|
||||
/* The fiber has been ready for more than 30 quantums: it's starving */
|
||||
if(nDiff > 30)
|
||||
{
|
||||
/* Plus one boost applied */
|
||||
++ b;
|
||||
|
||||
/* Apply the boost */
|
||||
pfdLastStarveScan->nBoost = 1;
|
||||
pfdLastStarveScan->nRealPrio = pfdLastStarveScan->nPrio;
|
||||
pfdLastStarveScan->nPrio = 15;
|
||||
|
||||
/* Re-enqueue the fiber in the correct priority queue */
|
||||
RemoveEntryList(&pfdLastStarveScan->leQueue);
|
||||
InsertTailList(&a_leQueues[15], &pfdLastStarveScan->leQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pfdNext = NULL;
|
||||
|
||||
/* This fiber is going to die: scan all ready queues */
|
||||
if(bExit)
|
||||
n = 1;
|
||||
/*
|
||||
Scan only ready queues for priorities greater than or equal to the priority of
|
||||
the current thread (round-robin)
|
||||
*/
|
||||
else
|
||||
n = pfdCur->nPrio + 1;
|
||||
|
||||
/* This loop scales O(1) */
|
||||
for(i = 32; i >= n; -- i)
|
||||
{
|
||||
PLIST_ENTRY pleNext;
|
||||
|
||||
/* No fiber ready for this priority level */
|
||||
if(IsListEmpty(&a_leQueues[i - 1]))
|
||||
continue;
|
||||
|
||||
/* Get the next ready fiber */
|
||||
pleNext = RemoveHeadList(&a_leQueues[i - 1]);
|
||||
InitializeListHead(pleNext);
|
||||
pfdNext = CONTAINING_RECORD(pleNext, struct FiberData, leQueue);
|
||||
assert(pfdNext->pFiber != GetCurrentFiber());
|
||||
assert(pfdNext->nMagic == 0x12345678);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Next fiber chosen */
|
||||
if(pfdNext)
|
||||
{
|
||||
/* Give some homework to the next fiber */
|
||||
pfdNext->pfdPrev = pfdCur;
|
||||
pfdNext->bExitPrev = bExit;
|
||||
|
||||
/* Switch to the next fiber */
|
||||
SwitchToFiber(pfdNext->pFiber);
|
||||
|
||||
/* Complete the switch back to this fiber */
|
||||
Fbt_AfterSwitch(pfdCur);
|
||||
}
|
||||
/* No next fiber, and current fiber exiting */
|
||||
else if(bExit)
|
||||
{
|
||||
PVOID pCurFiber;
|
||||
|
||||
/* Delete the current fiber. This kills the thread and stops the simulation */
|
||||
if(pfdLastStarveScan == pfdCur)
|
||||
pfdLastStarveScan = NULL;
|
||||
|
||||
pCurFiber = pfdCur->pFiber;
|
||||
free(pfdCur);
|
||||
DeleteFiber(pCurFiber);
|
||||
}
|
||||
/* No next fiber: continue running the current one */
|
||||
}
|
||||
|
||||
void Fbt_Exit(VOID)
|
||||
{
|
||||
Fbt_Dispatch(GetFiberData(), 1);
|
||||
}
|
||||
|
||||
void Fbt_CreateFiber(int bInitial)
|
||||
{
|
||||
PVOID pFiber;
|
||||
struct FiberData * pData;
|
||||
static int s_bFiberPrioSeeded = 0;
|
||||
static LONG s_nFiberIdSeed = 0;
|
||||
|
||||
pData = malloc(sizeof(struct FiberData));
|
||||
|
||||
assert(pData);
|
||||
|
||||
if(bInitial)
|
||||
pFiber = ConvertThreadToFiber(pData);
|
||||
else
|
||||
pFiber = CreateFiber(0, Fbt_Startup, pData);
|
||||
|
||||
if(!s_bFiberPrioSeeded)
|
||||
{
|
||||
unsigned nFiberPrioSeed;
|
||||
time_t tCurTime;
|
||||
|
||||
tCurTime = time(NULL);
|
||||
memcpy(&nFiberPrioSeed, &tCurTime, sizeof(nFiberPrioSeed));
|
||||
srand(nFiberPrioSeed);
|
||||
s_bFiberPrioSeeded = 1;
|
||||
}
|
||||
|
||||
assert(pFiber);
|
||||
|
||||
pData->nMagic = 0x12345678;
|
||||
pData->nId = InterlockedIncrement(&s_nFiberIdSeed);
|
||||
pData->nPrio = rand() % 32;
|
||||
pData->pFiber = pFiber;
|
||||
pData->nQuantumQueued = 0;
|
||||
pData->nBoost = 0;
|
||||
pData->nRealPrio = pData->nPrio;
|
||||
pData->pfdPrev = NULL;
|
||||
pData->bExitPrev = 0;
|
||||
|
||||
if(bInitial)
|
||||
{
|
||||
InitializeListHead(&pData->leQueue);
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertTailList
|
||||
(
|
||||
&a_leQueues[pData->nPrio],
|
||||
&pData->leQueue
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void DoStuff(void)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned n;
|
||||
unsigned nId;
|
||||
|
||||
n = rand() % 1000;
|
||||
nId = Fbt_GetCurrentId();
|
||||
|
||||
_ftprintf(stderr, _T("[%u] BEGIN\n"), nId);
|
||||
|
||||
for(i = 0; i < n; ++ i)
|
||||
{
|
||||
unsigned j;
|
||||
unsigned m;
|
||||
|
||||
_ftprintf(stderr, _T("[%u] [%u/%u]\n"), nId, i + 1, n);
|
||||
|
||||
m = rand() % 1000;
|
||||
|
||||
for(j = 0; j < m; ++ j)
|
||||
Sleep(0);
|
||||
|
||||
Fbt_Yield();
|
||||
}
|
||||
|
||||
_ftprintf(stderr, _T("[%u] END\n"), nId);
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR const * const * argv)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned nFibers;
|
||||
|
||||
if(argc > 1)
|
||||
nFibers = _tcstoul(argv[1], NULL, 0);
|
||||
else
|
||||
nFibers = FIBERTEST_COUNT;
|
||||
|
||||
for(i = 0; i < 32; ++ i)
|
||||
{
|
||||
InitializeListHead(&a_leQueues[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < nFibers; ++ i)
|
||||
Fbt_CreateFiber(i == 0);
|
||||
|
||||
Fbt_Startup(GetFiberData());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -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 = global_mem
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,181 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.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 = "GradientClass";
|
||||
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("GradientClass",
|
||||
"GradientFill 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);
|
||||
}
|
||||
|
||||
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
//DeleteObject(tf);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
TRIVERTEX vert [5] ;
|
||||
GRADIENT_TRIANGLE gTRi[3];
|
||||
GRADIENT_RECT gRect[2];
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
|
||||
vert [0] .x = 0;
|
||||
vert [0] .y = 0;
|
||||
vert [0] .Red = 0xff00;
|
||||
vert [0] .Green = 0xff00;
|
||||
vert [0] .Blue = 0xff00;
|
||||
vert [0] .Alpha = 0x0000;
|
||||
|
||||
vert [1] .x = 300;
|
||||
vert [1] .y = 20;
|
||||
vert [1] .Red = 0x0000;
|
||||
vert [1] .Green = 0x0000;
|
||||
vert [1] .Blue = 0xff00;
|
||||
vert [1] .Alpha = 0x0000;
|
||||
|
||||
vert [2] .x = 100;
|
||||
vert [2] .y = 200;
|
||||
vert [2] .Red = 0xff00;
|
||||
vert [2] .Green = 0x0000;
|
||||
vert [2] .Blue = 0x0000;
|
||||
vert [2] .Alpha = 0x0000;
|
||||
|
||||
vert [3] .x = 250;
|
||||
vert [3] .y = 300;
|
||||
vert [3] .Red = 0x8000;
|
||||
vert [3] .Green = 0x8000;
|
||||
vert [3] .Blue = 0x0000;
|
||||
vert [3] .Alpha = 0x0000;
|
||||
|
||||
vert [4] .x = 325;
|
||||
vert [4] .y = 300;
|
||||
vert [4] .Red = 0x0000;
|
||||
vert [4] .Green = 0xff00;
|
||||
vert [4] .Blue = 0x0000;
|
||||
vert [4] .Alpha = 0x0000;
|
||||
|
||||
gTRi[0].Vertex1 = 0;
|
||||
gTRi[0].Vertex2 = 1;
|
||||
gTRi[0].Vertex3 = 2;
|
||||
|
||||
gTRi[1].Vertex1 = 1;
|
||||
gTRi[1].Vertex2 = 2;
|
||||
gTRi[1].Vertex3 = 3;
|
||||
|
||||
gTRi[2].Vertex1 = 1;
|
||||
gTRi[2].Vertex2 = 3;
|
||||
gTRi[2].Vertex3 = 4;
|
||||
|
||||
GdiGradientFill(hDC,vert,5,&gTRi,3,GRADIENT_FILL_TRIANGLE);
|
||||
|
||||
|
||||
vert [0] .x = 5;
|
||||
vert [0] .y = 200;
|
||||
vert [0] .Red = 0x0000;
|
||||
vert [0] .Green = 0x0000;
|
||||
vert [0] .Blue = 0x0000;
|
||||
vert [0] .Alpha = 0x0000;
|
||||
|
||||
vert [1] .x = 90;
|
||||
vert [1] .y = 240;
|
||||
vert [1] .Red = 0x0000;
|
||||
vert [1] .Green = 0x0000;
|
||||
vert [1] .Blue = 0xff00;
|
||||
vert [1] .Alpha = 0x0000;
|
||||
|
||||
vert [2] .x = 5;
|
||||
vert [2] .y = 245;
|
||||
vert [2] .Red = 0x0000;
|
||||
vert [2] .Green = 0x0000;
|
||||
vert [2] .Blue = 0x0000;
|
||||
vert [2] .Alpha = 0x0000;
|
||||
|
||||
vert [3] .x = 90;
|
||||
vert [3] .y = 300;
|
||||
vert [3] .Red = 0x0000;
|
||||
vert [3] .Green = 0x0000;
|
||||
vert [3] .Blue = 0xff00;
|
||||
vert [3] .Alpha = 0x0000;
|
||||
|
||||
gRect[0].UpperLeft = 0;
|
||||
gRect[0].LowerRight = 1;
|
||||
|
||||
gRect[1].UpperLeft = 2;
|
||||
gRect[1].LowerRight = 3;
|
||||
|
||||
GdiGradientFill(hDC,vert,4,&gRect[0],1,GRADIENT_FILL_RECT_H);
|
||||
GdiGradientFill(hDC,vert,4,&gRect[1],1,GRADIENT_FILL_RECT_V);
|
||||
|
||||
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.1 2004/02/08 21:57:35 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = gradient
|
||||
|
||||
TARGET_SDKLIBS = 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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,132 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static GUITHREADINFO gti;
|
||||
//HFONT tf;
|
||||
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 = "GuiThreadInfoClass";
|
||||
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("GuiThreadInfoClass",
|
||||
"GetGUIThreadInfo",
|
||||
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);
|
||||
}
|
||||
|
||||
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
|
||||
gti.cbSize = sizeof(GUITHREADINFO);
|
||||
GetGUIThreadInfo(0, >i);
|
||||
|
||||
SetTimer(hWnd, 1, 1000, NULL);
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
//DeleteObject(tf);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
char str[255];
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
wsprintf(str, "flags: ");
|
||||
if(gti.flags & GUI_16BITTASK) lstrcat(str, "GUI_16BITTASK ");
|
||||
if(gti.flags & GUI_CARETBLINKING) lstrcat(str, "GUI_CARETBLINKING ");
|
||||
if(gti.flags & GUI_INMENUMODE) lstrcat(str, "GUI_INMENUMODE ");
|
||||
if(gti.flags & GUI_INMOVESIZE) lstrcat(str, "GUI_INMOVESIZE ");
|
||||
if(gti.flags & GUI_POPUPMENUMODE) lstrcat(str, "GUI_POPUPMENUMODE ");
|
||||
if(gti.flags & GUI_SYSTEMMENUMODE) lstrcat(str, "GUI_SYSTEMMENUMODE ");
|
||||
TextOut(hDC, 10, 10, str, strlen(str));
|
||||
|
||||
wsprintf(str, "hwndActive == %08X", gti.hwndActive);
|
||||
TextOut(hDC, 10, 30, str, strlen(str));
|
||||
wsprintf(str, "hwndFocus == %08X", gti.hwndFocus);
|
||||
TextOut(hDC, 10, 50, str, strlen(str));
|
||||
wsprintf(str, "hwndCapture == %08X", gti.hwndCapture);
|
||||
TextOut(hDC, 10, 70, str, strlen(str));
|
||||
wsprintf(str, "hwndMenuOwner == %08X", gti.hwndMenuOwner);
|
||||
TextOut(hDC, 10, 90, str, strlen(str));
|
||||
wsprintf(str, "hwndMoveSize == %08X", gti.hwndMoveSize);
|
||||
TextOut(hDC, 10, 110, str, strlen(str));
|
||||
wsprintf(str, "hwndCaret == %08X", gti.hwndCaret);
|
||||
TextOut(hDC, 10, 130, str, strlen(str));
|
||||
wsprintf(str, "rcCaret == (%lu, %lu, %lu, %lu)", gti.rcCaret.left, gti.rcCaret.top, gti.rcCaret.right, gti.rcCaret.bottom);
|
||||
TextOut(hDC, 10, 150, str, strlen(str));
|
||||
|
||||
wsprintf(str, "GetGuiResources for the current process: %08X", GetCurrentProcess());
|
||||
TextOut(hDC, 10, 180, str, strlen(str));
|
||||
wsprintf(str, "GetGuiResources: GR_GDIOBJECTS == %04X", GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS));
|
||||
TextOut(hDC, 10, 200, str, strlen(str));
|
||||
wsprintf(str, "GetGuiResources: GR_USEROBJECTS == %04x", GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS));
|
||||
TextOut(hDC, 10, 220, str, strlen(str));
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
GetGUIThreadInfo(0, >i);
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.1 2003/11/18 23:33:31 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = guithreadinfo
|
||||
|
||||
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,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,8 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
printf("Hello world\n");
|
||||
return(0);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
# $Id: makefile,v 1.17 2003/11/14 17:13:17 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = hello
|
||||
|
||||
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 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +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 = hivetest
|
||||
|
||||
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,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
Binary file not shown.
Before Width: | Height: | Size: 766 B |
|
@ -1,216 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef GetCursorInfo
|
||||
#define _GetCursorInfo
|
||||
#endif
|
||||
|
||||
const char titleDrwIco[] = "DrawIcon Output";
|
||||
const char titleMask[] = "Mask(AND image)";
|
||||
const char titleXor[] = "XOR(color image)";
|
||||
const char file[] = "Icon from file:";
|
||||
const char res[] = "Icon from Resorce:";
|
||||
const char cursor[] = "Current Cursor:";
|
||||
const char cursormask[] = "Cursor Mask Bitmap";
|
||||
const char cursorcolor[] = "Cursor Color Bitmap";
|
||||
|
||||
#ifdef _GetCursorInfo
|
||||
typedef BOOL (__stdcall *GETCURSORINFO) (CURSORINFO *CursorInfo);
|
||||
|
||||
static GETCURSORINFO GetCursorInfo = NULL;
|
||||
#endif
|
||||
|
||||
HFONT tf;
|
||||
HINSTANCE hInst;
|
||||
|
||||
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
MSG msg;
|
||||
HWND hWnd;
|
||||
|
||||
hInst = hInstance;
|
||||
|
||||
#ifdef _GetCursorInfo
|
||||
GetCursorInfo = (GETCURSORINFO)GetProcAddress(GetModuleHandleW(L"user32.dll"), "GetCursorInfo");
|
||||
#endif
|
||||
|
||||
wc.lpszClassName = "IconTestClass";
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
if (RegisterClass(&wc) == 0)
|
||||
{
|
||||
DbgPrint("RegisterClass failed (last error 0x%X)\n", GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
hWnd = CreateWindow("IconTestClass",
|
||||
"Icon Test",
|
||||
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
480,
|
||||
480,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
DbgPrint("CreateWindow failed (last error 0x%X)\n", GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
tf = CreateFontA(14,0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
SetTimer(hWnd, 1, 1000, NULL);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
HICON hIcon;
|
||||
HGDIOBJ hOld;
|
||||
HDC hMemDC;
|
||||
CURSORINFO cursorinfo;
|
||||
ICONINFO iconinfo;
|
||||
BITMAP bmp;
|
||||
RECT rc;
|
||||
CHAR str[20];
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
SelectObject(hDC, tf);
|
||||
SetBkMode(hDC, TRANSPARENT);
|
||||
|
||||
TextOut(hDC, 160, 10, file, strlen(file));
|
||||
TextOut(hDC, 15, 85, titleDrwIco, strlen(titleDrwIco));
|
||||
TextOut(hDC, 160, 85, titleMask, strlen(titleMask));
|
||||
TextOut(hDC, 300, 85, titleXor, strlen(titleXor));
|
||||
|
||||
hIcon = LoadImage(NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE);
|
||||
DrawIcon(hDC,50,50,hIcon);
|
||||
|
||||
hMemDC = CreateCompatibleDC(hDC);
|
||||
GetIconInfo(hIcon, &iconinfo);
|
||||
DestroyIcon(hIcon);
|
||||
|
||||
hOld = SelectObject(hMemDC, iconinfo.hbmMask);
|
||||
BitBlt(hDC, 200, 50, 32, 32, hMemDC, 0, 0, SRCCOPY);
|
||||
SelectObject(hMemDC, iconinfo.hbmColor);
|
||||
BitBlt(hDC, 350, 50, 32, 32, hMemDC, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteObject(iconinfo.hbmMask);
|
||||
DeleteObject(iconinfo.hbmColor);
|
||||
|
||||
TextOut(hDC, 145, 150, res, strlen(res));
|
||||
TextOut(hDC, 15, 225, titleDrwIco, strlen(titleDrwIco));
|
||||
TextOut(hDC, 160, 225, titleMask, strlen(titleMask));
|
||||
TextOut(hDC, 300, 225, titleXor, strlen(titleXor));
|
||||
|
||||
hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
|
||||
DrawIcon(hDC,50,190,hIcon);
|
||||
|
||||
GetIconInfo(hIcon, &iconinfo);
|
||||
DestroyIcon(hIcon);
|
||||
|
||||
SelectObject(hMemDC, iconinfo.hbmMask);
|
||||
BitBlt(hDC, 200, 190, 32, 32, hMemDC, 0, 0, SRCCOPY);
|
||||
SelectObject(hMemDC, iconinfo.hbmColor);
|
||||
BitBlt(hDC, 350, 190, 32, 32, hMemDC, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteObject(iconinfo.hbmMask);
|
||||
DeleteObject(iconinfo.hbmColor);
|
||||
|
||||
cursorinfo.cbSize = sizeof(CURSORINFO);
|
||||
if(GetCursorInfo(&cursorinfo))
|
||||
{
|
||||
if(cursorinfo.hCursor && cursorinfo.flags)
|
||||
{
|
||||
TextOut(hDC, 160, 290, cursor, strlen(cursor));
|
||||
DrawIcon(hDC, 50, 330, cursorinfo.hCursor);
|
||||
GetIconInfo(cursorinfo.hCursor, &iconinfo);
|
||||
TextOut(hDC, 15, 365, titleDrwIco, strlen(titleDrwIco));
|
||||
|
||||
sprintf(str, "Hotspot: %ld; %ld", iconinfo.xHotspot, iconinfo.yHotspot);
|
||||
TextOut(hDC, 15, 380, str, strlen(str));
|
||||
|
||||
if(iconinfo.hbmMask)
|
||||
{
|
||||
GetObjectW(iconinfo.hbmMask, sizeof(BITMAP), &bmp);
|
||||
SelectObject(hMemDC, iconinfo.hbmMask);
|
||||
BitBlt(hDC, 200, 330, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
|
||||
DeleteObject(iconinfo.hbmMask);
|
||||
TextOut(hDC, 160, 365 - 32 + bmp.bmHeight, cursormask, strlen(cursormask));
|
||||
|
||||
sprintf(str, "%dBPP", bmp.bmBitsPixel);
|
||||
TextOut(hDC, 160, 380 - 32 + bmp.bmHeight, str, strlen(str));
|
||||
}
|
||||
|
||||
if(iconinfo.hbmColor)
|
||||
{
|
||||
GetObjectW(iconinfo.hbmColor, sizeof(BITMAP), &bmp);
|
||||
SelectObject(hMemDC, iconinfo.hbmColor);
|
||||
BitBlt(hDC, 350, 330, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
|
||||
DeleteObject(iconinfo.hbmColor);
|
||||
TextOut(hDC, 300, 365 - 32 + bmp.bmHeight, cursorcolor, strlen(cursorcolor));
|
||||
|
||||
sprintf(str, "%dBPP", bmp.bmBitsPixel);
|
||||
TextOut(hDC, 300, 380 - 32 + bmp.bmHeight, str, strlen(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject(hMemDC, hOld);
|
||||
|
||||
DeleteObject(hMemDC);
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
rc.left = 0;
|
||||
rc.top = 330;
|
||||
rc.right = 480;
|
||||
rc.bottom = 480;
|
||||
InvalidateRect(hWnd, &rc, TRUE);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
#include "resource.h"
|
||||
|
||||
IDI_ICON ICON DISCARDABLE "icon.ico"
|
|
@ -1,21 +0,0 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = no
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = icontest
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a gdi32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1 +0,0 @@
|
|||
#define IDI_ICON 101
|
|
@ -1,476 +0,0 @@
|
|||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
extern "C" {
|
||||
typedef unsigned short u_short;
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ddk/tdi.h>
|
||||
#include <ddk/tdikrnl.h>
|
||||
#include <ddk/tdiinfo.h>
|
||||
#include <ddk/ndis.h>
|
||||
#include <titypes.h>
|
||||
#include <ip.h>
|
||||
#include <tcp.h>
|
||||
#include <receive.h>
|
||||
#include <lan.h>
|
||||
#include <routines.h>
|
||||
};
|
||||
|
||||
/* Undis */
|
||||
extern "C" VOID ExpInitLookasideLists();
|
||||
|
||||
std::list<std::string> output_packets;
|
||||
DWORD DebugTraceLevel = 0x7fffffff;
|
||||
PVOID GlobalBufferPool, GlobalPacketPool;
|
||||
|
||||
#define MAX_DG_SIZE 16384
|
||||
|
||||
char hwaddr[6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb };
|
||||
|
||||
char hdr[14] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00 };
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
|
||||
void display_row( char *data, int off, int len ) {
|
||||
int i;
|
||||
|
||||
printf( "%08x:", off );
|
||||
for( i = off; i < len && i < off + 16; i++ ) {
|
||||
printf( " %02x", data[i] & 0xff );
|
||||
}
|
||||
|
||||
printf( " -- " );
|
||||
|
||||
for( i = off; i < len && i < off + 16; i++ ) {
|
||||
printf( "%c", (data[i] >= ' ') ? data[i] : '.' );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void connect_complete( void *context, NTSTATUS status, unsigned long count ) {
|
||||
printf( "Connection: status %x\n", status );
|
||||
}
|
||||
|
||||
void receive_complete( void *context, NTSTATUS status, unsigned long count ) {
|
||||
printf( "Receive: status %s (bytes %d)\n", status, count );
|
||||
if( !status && count ) {
|
||||
for( int off = 0; off < count; off += 16 ) {
|
||||
display_row( (char *)context, off, count );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
class SocketObject {
|
||||
public:
|
||||
virtual ~SocketObject() { }
|
||||
virtual int send( char *buf, int len, int *bytes,
|
||||
struct sockaddr_in *si ) = 0;
|
||||
virtual int recv( char *buf, int len, int *bytes,
|
||||
struct sockaddr_in *si ) = 0;
|
||||
};
|
||||
|
||||
UINT TdiAddressSizeFromType( UINT AddressType ) {
|
||||
switch( AddressType ) {
|
||||
case TDI_ADDRESS_TYPE_IP:
|
||||
return sizeof(TA_IP_ADDRESS);
|
||||
default:
|
||||
KeBugCheck( 0 );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
NTSTATUS TdiBuildNullConnectionInfoInPlace
|
||||
( PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
ULONG Type )
|
||||
/*
|
||||
* FUNCTION: Builds a NULL TDI connection information structure
|
||||
* ARGUMENTS:
|
||||
* ConnectionInfo = Address of buffer to place connection information
|
||||
* Type = TDI style address type (TDI_ADDRESS_TYPE_XXX).
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
ULONG TdiAddressSize;
|
||||
|
||||
TdiAddressSize = TdiAddressSizeFromType(Type);
|
||||
|
||||
RtlZeroMemory(ConnInfo,
|
||||
sizeof(TDI_CONNECTION_INFORMATION) +
|
||||
TdiAddressSize);
|
||||
|
||||
ConnInfo->OptionsLength = sizeof(ULONG);
|
||||
ConnInfo->RemoteAddressLength = 0;
|
||||
ConnInfo->RemoteAddress = NULL;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS TdiBuildNullConnectionInfo
|
||||
( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
|
||||
ULONG Type )
|
||||
/*
|
||||
* FUNCTION: Builds a NULL TDI connection information structure
|
||||
* ARGUMENTS:
|
||||
* ConnectionInfo = Address of buffer pointer to allocate connection
|
||||
* information in
|
||||
* Type = TDI style address type (TDI_ADDRESS_TYPE_XXX).
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo;
|
||||
ULONG TdiAddressSize;
|
||||
NTSTATUS Status;
|
||||
|
||||
TdiAddressSize = TdiAddressSizeFromType(Type);
|
||||
|
||||
ConnInfo = (PTDI_CONNECTION_INFORMATION)
|
||||
ExAllocatePool(NonPagedPool,
|
||||
sizeof(TDI_CONNECTION_INFORMATION) +
|
||||
TdiAddressSize);
|
||||
if (!ConnInfo)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
Status = TdiBuildNullConnectionInfoInPlace( ConnInfo, Type );
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ExFreePool( ConnInfo );
|
||||
else
|
||||
*ConnectionInfo = ConnInfo;
|
||||
|
||||
ConnInfo->RemoteAddress = (PTA_ADDRESS)&ConnInfo[1];
|
||||
ConnInfo->RemoteAddressLength = TdiAddressSize;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
UINT TaLengthOfTransportAddress( PTRANSPORT_ADDRESS Addr ) {
|
||||
UINT AddrLen = 2 * sizeof( ULONG ) + Addr->Address[0].AddressLength;
|
||||
printf("AddrLen %x\n", AddrLen);
|
||||
return AddrLen;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
TdiBuildConnectionInfoInPlace
|
||||
( PTDI_CONNECTION_INFORMATION ConnectionInfo,
|
||||
PTA_ADDRESS Address ) {
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
RtlCopyMemory( ConnectionInfo->RemoteAddress,
|
||||
Address,
|
||||
ConnectionInfo->RemoteAddressLength );
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
TdiBuildConnectionInfo
|
||||
( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
|
||||
PTA_ADDRESS Address ) {
|
||||
NTSTATUS Status = TdiBuildNullConnectionInfo( ConnectionInfo,
|
||||
Address->AddressType );
|
||||
|
||||
if( NT_SUCCESS(Status) )
|
||||
TdiBuildConnectionInfoInPlace( *ConnectionInfo, Address );
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
class TCPSocketObject : public SocketObject {
|
||||
public:
|
||||
TCPSocketObject( std::string host, int port, NTSTATUS *status ) {
|
||||
TA_IP_ADDRESS ConnectTo;
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo;
|
||||
|
||||
ConnectTo.TAAddressCount = 1;
|
||||
ConnectTo.Address[0].AddressLength = sizeof(TDI_ADDRESS_IP);
|
||||
ConnectTo.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
|
||||
ConnectTo.Address[0].Address[0].sin_port = htons(port);
|
||||
ConnectTo.Address[0].Address[0].in_addr = 0x6a020a0a;
|
||||
|
||||
TdiBuildConnectionInfo( &ConnInfo, (PTA_ADDRESS)&ConnectTo );
|
||||
|
||||
Connection = TCPAllocateConnectionEndpoint( NULL );
|
||||
*status = TCPSocket( Connection,
|
||||
AF_INET,
|
||||
SOCK_STREAM, IPPROTO_TCP );
|
||||
if( !*status )
|
||||
*status = TCPConnect( Connection,
|
||||
ConnInfo,
|
||||
NULL,
|
||||
connect_complete,
|
||||
NULL );
|
||||
}
|
||||
|
||||
~TCPSocketObject() {
|
||||
TCPClose( Connection );
|
||||
if( Connection ) TCPFreeConnectionEndpoint( Connection );
|
||||
}
|
||||
|
||||
int send( char *buf, int len, int *bytes, struct sockaddr_in *si ) {
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if( Connection )
|
||||
Status = TCPSendData( Connection,
|
||||
buf,
|
||||
len,
|
||||
(PULONG)bytes,
|
||||
0 );
|
||||
return Status;
|
||||
}
|
||||
|
||||
int recv( char *buf, int len, int *bytes, struct sockaddr_in *si ) {
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if( Connection )
|
||||
Status = TCPSendData( Connection,
|
||||
buf,
|
||||
len,
|
||||
(PULONG)bytes,
|
||||
0 );
|
||||
return Status;
|
||||
}
|
||||
|
||||
private:
|
||||
PCONNECTION_ENDPOINT Connection;
|
||||
};
|
||||
|
||||
VOID SendPacket( PVOID Context,
|
||||
PNDIS_PACKET NdisPacket,
|
||||
UINT Offset,
|
||||
PVOID LinkAddress,
|
||||
USHORT Type ) {
|
||||
PCHAR DataOut;
|
||||
PUCHAR Addr = (PUCHAR)LinkAddress;
|
||||
UINT Size;
|
||||
std::string output_packet;
|
||||
|
||||
printf( "Sending packet: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5] );
|
||||
|
||||
GetDataPtr( NdisPacket, Offset, &DataOut, &Size );
|
||||
for( int off = 0; off < Size; off += 16 ) {
|
||||
display_row( DataOut, off, Size );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
output_packet += std::string( hwaddr, sizeof(hwaddr) );
|
||||
output_packet += std::string( (char *)LinkAddress, sizeof(hwaddr) );
|
||||
output_packet += (char)(Type >> 8);
|
||||
output_packet += (char)Type;
|
||||
output_packet += std::string( DataOut + Offset, Size - Offset );
|
||||
|
||||
output_packets.push_back( output_packet );
|
||||
}
|
||||
|
||||
#if 0
|
||||
UINT CopyBufferToBufferChain
|
||||
( PNDIS_BUFFER DstBuffer, UINT DstOffset, PCHAR SrcData, UINT Length ) {
|
||||
assert( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
|
||||
int bytes, adapter_id, mtu, speed;
|
||||
char datagram[MAX_DG_SIZE];
|
||||
struct fd_set readf;
|
||||
struct timeval tv;
|
||||
struct sockaddr_in addr_from = { AF_INET }, addr_to;
|
||||
std::string word, cmdin, host;
|
||||
std::list<std::string>::iterator i;
|
||||
WSADATA wsadata;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING RegistryUnicodePath;
|
||||
PCONNECTION_ENDPOINT Connection;
|
||||
PIP_INTERFACE Interface;
|
||||
IP_PACKET IPPacket;
|
||||
LLIP_BIND_INFO BindInfo;
|
||||
SocketObject *S = NULL;
|
||||
|
||||
RtlInitUnicodeString
|
||||
( &RegistryUnicodePath,
|
||||
L"\\SYSTEM\\CurrentControlSet\\Services"
|
||||
L"\\Tcpip" );
|
||||
|
||||
ExpInitLookasideLists();
|
||||
|
||||
WSAStartup( 0x101, &wsadata );
|
||||
|
||||
if( argc > 1 ) port = atoi(argv[1]);
|
||||
|
||||
IPStartup( &RegistryUnicodePath );
|
||||
|
||||
BindInfo.Context = NULL;
|
||||
BindInfo.HeaderSize = sizeof(ETH_HEADER);
|
||||
BindInfo.MTU = 1500; /* MTU for ethernet */
|
||||
BindInfo.Address = (PUCHAR)hwaddr;
|
||||
BindInfo.AddressLength = sizeof(hwaddr);
|
||||
BindInfo.Transmit = SendPacket;
|
||||
|
||||
IPCreateInterface( &BindInfo );
|
||||
|
||||
asock = socket( AF_INET, SOCK_DGRAM, 0 );
|
||||
|
||||
addr_from.sin_port = htons( port );
|
||||
|
||||
if( bind( asock, (struct sockaddr *)&addr_from, sizeof( addr_from ) ) ) {
|
||||
printf( "Bind error\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
while( true ) {
|
||||
FD_ZERO( &readf );
|
||||
FD_SET( asock, &readf );
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 10000;
|
||||
selret = select( asock + 1, &readf, NULL, NULL, &tv );
|
||||
|
||||
if( FD_ISSET( asock, &readf ) ) {
|
||||
fromsize = sizeof( addr_from );
|
||||
dgrecv = recvfrom( asock, datagram, sizeof(datagram), 0,
|
||||
(struct sockaddr *)&addr_from, &fromsize );
|
||||
|
||||
if( datagram[0] == 'C' && datagram[1] == 'M' &&
|
||||
datagram[2] == 'D' && datagram[3] == ' ' ) {
|
||||
int theport, bytes, recvret, off, bytin;
|
||||
struct sockaddr_in nam;
|
||||
std::string faddr, word;
|
||||
std::istringstream
|
||||
cmdin( std::string( datagram + 4, dgrecv - 4 ) );
|
||||
|
||||
cmdin >> word;
|
||||
|
||||
/* UDP Section */
|
||||
if( word == "udpsocket" ) {
|
||||
/* TCP Section */
|
||||
} else if( word == "tcpsocket" ) {
|
||||
cmdin >> host >> port;
|
||||
S = new TCPSocketObject( host, port, &Status );
|
||||
fprintf( stderr, "Socket: Result %x\n", Status );
|
||||
} else if( word == "close" ) {
|
||||
TCPClose( Connection );
|
||||
TCPFreeConnectionEndpoint( Connection );
|
||||
} else if( word == "type" ) {
|
||||
std::string therest = &cmdin.str()[word.size()];
|
||||
char* p = &therest[0];
|
||||
p += strspn ( p, " \t" );
|
||||
char* src = p;
|
||||
char* dst = p;
|
||||
while ( *src )
|
||||
{
|
||||
char c = *src++;
|
||||
if ( c == '\r' || c == '\n' ) break;
|
||||
if ( c == '\\' )
|
||||
{
|
||||
c = *src++;
|
||||
switch ( c )
|
||||
{
|
||||
case 'b': c = '\b'; break;
|
||||
case 'n': c = '\n'; break;
|
||||
case 'r': c = '\r'; break;
|
||||
case 't': c = '\t'; break;
|
||||
case 'v': c = '\v'; break;
|
||||
}
|
||||
}
|
||||
*dst++ = c;
|
||||
}
|
||||
*dst = '\0';
|
||||
if( S )
|
||||
err = S->send( p, strlen(p), &bytes, NULL );
|
||||
if( err > 0 ) { bytin = err; err = 0; }
|
||||
|
||||
if( err )
|
||||
fprintf ( stderr, "OskitTCPConnect: error %d\n",
|
||||
err );
|
||||
else {
|
||||
printf ( "wrote %d bytes\n", bytin );
|
||||
}
|
||||
} else if( word == "send" ) {
|
||||
off = 0;
|
||||
while( cmdin >> word ) {
|
||||
datagram[off++] =
|
||||
atoi( (std::string("0x") + word).c_str() );
|
||||
}
|
||||
|
||||
if( (err = S->send( datagram, off, &bytin, NULL )) != 0 ) {
|
||||
fprintf( stderr, "OskitTCPConnect: error %d\n", err );
|
||||
} else {
|
||||
printf( "wrote %d bytes\n", bytin );
|
||||
}
|
||||
} else if( word == "recv" ) {
|
||||
cmdin >> bytes;
|
||||
|
||||
if( (err = S->recv( datagram,
|
||||
sizeof(datagram),
|
||||
&bytes,
|
||||
NULL )) != 0 ) {
|
||||
fprintf( stderr, "OskitTCPRecv: error %d\n", err );
|
||||
}
|
||||
|
||||
/* Misc section */
|
||||
} else if( word == "end" ) {
|
||||
return 0;
|
||||
}
|
||||
} else if( dgrecv > 14 ) {
|
||||
addr_to = addr_from;
|
||||
|
||||
if( datagram[12] == 8 && datagram[13] == 6 ) {
|
||||
/* Answer arp query */
|
||||
char laddr[4];
|
||||
/* Mark patch as to the previous sender */
|
||||
memcpy( datagram + 32, datagram + 6, 6 );
|
||||
memcpy( datagram, datagram + 6, 6 );
|
||||
/* Mark packet as from us */
|
||||
memcpy( datagram + 22, hwaddr, 6 );
|
||||
memcpy( datagram + 6, hwaddr, 6 );
|
||||
/* Swap inet addresses */
|
||||
memcpy( laddr, datagram + 28, 4 );
|
||||
memcpy( datagram + 28, datagram + 38, 4 );
|
||||
memcpy( datagram + 38, laddr, 4 );
|
||||
/* Set reply opcode */
|
||||
datagram[21] = 2;
|
||||
|
||||
err = sendto( asock, datagram, dgrecv, 0,
|
||||
(struct sockaddr *)&addr_to,
|
||||
sizeof(addr_to) );
|
||||
|
||||
if( err != 0 )
|
||||
printf( "sendto: %d\n", err );
|
||||
} else {
|
||||
memcpy( hdr, datagram + 6, 6 );
|
||||
memcpy( hdr + 6, datagram, 6 );
|
||||
memcpy( hdr + 12, datagram + 12, 2 );
|
||||
IPPacket.Header = datagram;
|
||||
IPPacket.Data = datagram + 14;
|
||||
IPPacket.TotalSize = dgrecv;
|
||||
IPReceive( Interface, &IPPacket );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IPTimeout(NULL, NULL, NULL, NULL);
|
||||
|
||||
for( i = output_packets.begin(); i != output_packets.end(); i++ ) {
|
||||
err = sendto( asock, i->c_str(), i->size(), 0,
|
||||
(struct sockaddr *)&addr_to, sizeof(addr_to) );
|
||||
|
||||
fprintf( stderr, "** SENDING PACKET %d bytes **\n", i->size() );
|
||||
|
||||
if( err != 0 )
|
||||
printf( "sendto: %d\n", err );
|
||||
}
|
||||
|
||||
output_packets.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# $Id: makefile,v 1.1 2004/10/04 04:26:00 arty Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = iptest
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a ip.a oskittcp.a undis.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = iptest.o
|
||||
|
||||
TARGET_CPPFLAGS = -I$(PATH_TO_TOP)/drivers/lib/oskittcp/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/drivers/net/tcpip/include -g
|
||||
|
||||
TARGET_GCCLIBS = stdc++
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,230 +0,0 @@
|
|||
/*
|
||||
* isotest - display cdrom information
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
//#include <winioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
void HexDump(char *buffer, ULONG size)
|
||||
{
|
||||
ULONG offset = 0;
|
||||
unsigned char *ptr;
|
||||
|
||||
while (offset < (size & ~15))
|
||||
{
|
||||
ptr = (unsigned char*)((ULONG)buffer + offset);
|
||||
printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
|
||||
offset,
|
||||
ptr[0],
|
||||
ptr[1],
|
||||
ptr[2],
|
||||
ptr[3],
|
||||
ptr[4],
|
||||
ptr[5],
|
||||
ptr[6],
|
||||
ptr[7],
|
||||
ptr[8],
|
||||
ptr[9],
|
||||
ptr[10],
|
||||
ptr[11],
|
||||
ptr[12],
|
||||
ptr[13],
|
||||
ptr[14],
|
||||
ptr[15]);
|
||||
|
||||
printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
|
||||
isprint(ptr[0])?ptr[0]:'.',
|
||||
isprint(ptr[1])?ptr[1]:'.',
|
||||
isprint(ptr[2])?ptr[2]:'.',
|
||||
isprint(ptr[3])?ptr[3]:'.',
|
||||
isprint(ptr[4])?ptr[4]:'.',
|
||||
isprint(ptr[5])?ptr[5]:'.',
|
||||
isprint(ptr[6])?ptr[6]:'.',
|
||||
isprint(ptr[7])?ptr[7]:'.',
|
||||
isprint(ptr[8])?ptr[8]:'.',
|
||||
isprint(ptr[9])?ptr[9]:'.',
|
||||
isprint(ptr[10])?ptr[10]:'.',
|
||||
isprint(ptr[11])?ptr[11]:'.',
|
||||
isprint(ptr[12])?ptr[12]:'.',
|
||||
isprint(ptr[13])?ptr[13]:'.',
|
||||
isprint(ptr[14])?ptr[14]:'.',
|
||||
isprint(ptr[15])?ptr[15]:'.');
|
||||
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
ptr = (unsigned char*)((ULONG)buffer + offset);
|
||||
if (offset < size)
|
||||
{
|
||||
printf("%08lx ", offset);
|
||||
while (offset < size)
|
||||
{
|
||||
printf(" %02hx", *ptr);
|
||||
offset++;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
|
||||
#ifndef EVENT_ALL_ACCESS
|
||||
#define EVENT_ALL_ACCESS (0x1f0003L)
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
ReadBlock(HANDLE FileHandle,
|
||||
PVOID Buffer,
|
||||
PLARGE_INTEGER Offset,
|
||||
ULONG Length,
|
||||
PULONG BytesRead)
|
||||
{
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
NTSTATUS Status;
|
||||
HANDLE EventHandle;
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
NULL, 0, NULL, NULL);
|
||||
|
||||
Status = NtCreateEvent(&EventHandle,
|
||||
EVENT_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
TRUE,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("NtCreateEvent() failed\n");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
Status = NtReadFile(FileHandle,
|
||||
EventHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
Buffer,
|
||||
Length,
|
||||
Offset,
|
||||
NULL);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
NtWaitForSingleObject(EventHandle, FALSE, NULL);
|
||||
Status = IoStatusBlock.Status;
|
||||
}
|
||||
|
||||
NtClose(EventHandle);
|
||||
|
||||
if (Status != STATUS_PENDING && BytesRead != NULL)
|
||||
{
|
||||
*BytesRead = IoStatusBlock.Information;
|
||||
}
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
|
||||
{
|
||||
printf("ReadBlock() failed (Status: %lx)\n", Status);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
HANDLE hDisk;
|
||||
DWORD dwRead;
|
||||
char *Buffer;
|
||||
CHAR Filename[80];
|
||||
LARGE_INTEGER FilePosition;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Usage: isotest [Drive:]\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(Filename, "\\\\.\\");
|
||||
strcat(Filename, argv[1]);
|
||||
|
||||
hDisk = CreateFile(Filename,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL);
|
||||
if (hDisk == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("CreateFile(): Invalid disk handle!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Buffer = (char*)malloc(2048);
|
||||
if (Buffer == NULL)
|
||||
{
|
||||
CloseHandle(hDisk);
|
||||
printf("Out of memory!\n");
|
||||
return 0;
|
||||
}
|
||||
memset(Buffer, 0, 2048);
|
||||
|
||||
|
||||
FilePosition.QuadPart = 16 * 2048;
|
||||
#if 0
|
||||
SetLastError(NO_ERROR);
|
||||
SetFilePointer(hDisk,
|
||||
FilePosition.u.LowPart,
|
||||
&FilePosition.u.HighPart,
|
||||
FILE_BEGIN);
|
||||
if (GetLastError() != NO_ERROR)
|
||||
{
|
||||
CloseHandle(hDisk);
|
||||
free(Buffer);
|
||||
printf("SetFilePointer() failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ReadFile(hDisk,
|
||||
Buffer,
|
||||
2048,
|
||||
&dwRead,
|
||||
NULL) == FALSE)
|
||||
{
|
||||
CloseHandle(hDisk);
|
||||
free(Buffer);
|
||||
printf("ReadFile() failed!\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ReadBlock(hDisk,
|
||||
Buffer,
|
||||
&FilePosition,
|
||||
2048,
|
||||
&dwRead) == FALSE)
|
||||
{
|
||||
CloseHandle(hDisk);
|
||||
free(Buffer);
|
||||
#if 0
|
||||
printf("ReadBlock() failed!\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
HexDump(Buffer, 128);
|
||||
|
||||
CloseHandle(hDisk);
|
||||
|
||||
free(Buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,25 +0,0 @@
|
|||
# $Id: makefile,v 1.3 2003/11/14 17:13:17 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = isotest
|
||||
|
||||
#TARGET_CFLAGS = -fnative_struct
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,46 +0,0 @@
|
|||
# $Id: Makefile,v 1.2 2004/05/04 17:25:18 navaraf Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
# require os code to explicitly request A/W version of structs/functions
|
||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API -DWINVER=0x0500
|
||||
|
||||
TARGET_NAME = kernel32_test
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
testlist.o \
|
||||
atom.o \
|
||||
change.o \
|
||||
codepage.o \
|
||||
comm.o \
|
||||
console.o \
|
||||
directory.o \
|
||||
drive.o \
|
||||
environ.o \
|
||||
file.o \
|
||||
format_msg.o \
|
||||
heap.o \
|
||||
locale.o \
|
||||
mailslot.o \
|
||||
path.o \
|
||||
pipe.o \
|
||||
process.o \
|
||||
profile.o \
|
||||
thread.o \
|
||||
virtual.o
|
||||
|
||||
#FIXME alloc.o \
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,33 +0,0 @@
|
|||
TOPSRCDIR = @top_srcdir@
|
||||
TOPOBJDIR = ../../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = kernel32.dll
|
||||
IMPORTS = kernel32
|
||||
|
||||
CTESTS = \
|
||||
alloc.c \
|
||||
atom.c \
|
||||
change.c \
|
||||
codepage.c \
|
||||
comm.c \
|
||||
console.c \
|
||||
directory.c \
|
||||
drive.c \
|
||||
environ.c \
|
||||
file.c \
|
||||
format_msg.c \
|
||||
generated.c \
|
||||
heap.c \
|
||||
locale.c \
|
||||
mailslot.c \
|
||||
path.c \
|
||||
pipe.c \
|
||||
process.c \
|
||||
profile.c \
|
||||
thread.c \
|
||||
virtual.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
### Dependencies:
|
|
@ -1,408 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for memory allocation functions.
|
||||
*
|
||||
* Copyright 2002 Geoffrey Hausheer
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
||||
|
||||
/* The following functions don't have tests, because either I don't know how
|
||||
to test them, or they are WinNT only, or require multiple threads.
|
||||
Since the last two issues shouldn't really stop the tests from being
|
||||
written, assume for now that it is all due to the first case
|
||||
HeapCompact
|
||||
HeapLock
|
||||
HeapQueryInformation
|
||||
HeapSetInformation
|
||||
HeapUnlock
|
||||
HeapValidate
|
||||
HeapWalk
|
||||
*/
|
||||
/* In addition, these features aren't being tested
|
||||
HEAP_NO_SERIALIZE
|
||||
HEAP_GENERATE_EXCEPTIONS
|
||||
STATUS_ACCESS_VIOLATION (error code from HeapAlloc)
|
||||
*/
|
||||
|
||||
static void test_Heap(void)
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
ULONG memchunk;
|
||||
HANDLE heap;
|
||||
LPVOID mem1,mem1a,mem3;
|
||||
UCHAR *mem2,*mem2a;
|
||||
UINT error,i;
|
||||
DWORD dwSize;
|
||||
|
||||
/* Retrieve the page size for this system */
|
||||
sysInfo.dwPageSize=0;
|
||||
GetSystemInfo(&sysInfo);
|
||||
ok(sysInfo.dwPageSize>0,"GetSystemInfo should return a valid page size\n");
|
||||
|
||||
/* Create a Heap with a minimum and maximum size */
|
||||
/* Note that Windows and Wine seem to behave a bit differently with respect
|
||||
to memory allocation. In Windows, you can't access all the memory
|
||||
specified in the heap (due to overhead), so choosing a reasonable maximum
|
||||
size for the heap was done mostly by trial-and-error on Win2k. It may need
|
||||
more tweaking for otherWindows variants.
|
||||
*/
|
||||
memchunk=10*sysInfo.dwPageSize;
|
||||
heap=HeapCreate(0,2*memchunk,5*memchunk);
|
||||
|
||||
/* Check that HeapCreate allocated the right amount of ram */
|
||||
todo_wine {
|
||||
/* Today HeapCreate seems to return a memory block larger than specified.
|
||||
MSDN says the maximum heap size should be dwMaximumSize rounded up to the
|
||||
nearest page boundary
|
||||
*/
|
||||
mem1=HeapAlloc(heap,0,5*memchunk+1);
|
||||
ok(mem1==NULL,"HeapCreate allocated more Ram than it should have\n");
|
||||
if(mem1) {
|
||||
HeapFree(heap,0,mem1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that a normal alloc works */
|
||||
mem1=HeapAlloc(heap,0,memchunk);
|
||||
ok(mem1!=NULL,"HeapAlloc failed\n");
|
||||
if(mem1) {
|
||||
ok(HeapSize(heap,0,mem1)>=memchunk, "HeapAlloc should return a big enough memory block\n");
|
||||
}
|
||||
|
||||
/* Check that a 'zeroing' alloc works */
|
||||
mem2=HeapAlloc(heap,HEAP_ZERO_MEMORY,memchunk);
|
||||
ok(mem2!=NULL,"HeapAlloc failed\n");
|
||||
if(mem2) {
|
||||
ok(HeapSize(heap,0,mem2)>=memchunk,"HeapAlloc should return a big enough memory block\n");
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i++) {
|
||||
if(mem2[i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"HeapAlloc should have zeroed out it's allocated memory\n");
|
||||
}
|
||||
|
||||
/* Check that HeapAlloc returns NULL when requested way too much memory */
|
||||
mem3=HeapAlloc(heap,0,5*memchunk);
|
||||
ok(mem3==NULL,"HeapAlloc should return NULL\n");
|
||||
if(mem3) {
|
||||
ok(HeapFree(heap,0,mem3),"HeapFree didn't pass successfully\n");
|
||||
}
|
||||
|
||||
/* Check that HeapRealloc works */
|
||||
mem2a=HeapReAlloc(heap,HEAP_ZERO_MEMORY,mem2,memchunk+5*sysInfo.dwPageSize);
|
||||
ok(mem2a!=NULL,"HeapReAlloc failed\n");
|
||||
if(mem2a) {
|
||||
ok(HeapSize(heap,0,mem2a)>=memchunk+5*sysInfo.dwPageSize,"HeapReAlloc failed\n");
|
||||
error=0;
|
||||
for(i=0;i<5*sysInfo.dwPageSize;i++) {
|
||||
if(mem2a[memchunk+i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"HeapReAlloc should have zeroed out it's allocated memory\n");
|
||||
}
|
||||
|
||||
/* Check that HeapRealloc honours HEAP_REALLOC_IN_PLACE_ONLY */
|
||||
error=0;
|
||||
mem1a=HeapReAlloc(heap,HEAP_REALLOC_IN_PLACE_ONLY,mem1,memchunk+sysInfo.dwPageSize);
|
||||
if(mem1a!=NULL) {
|
||||
if(mem1a!=mem1) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(mem1a==NULL || error==0,"HeapReAlloc didn't honour HEAP_REALLOC_IN_PLACE_ONLY\n");
|
||||
|
||||
/* Check that HeapFree works correctly */
|
||||
if(mem1a) {
|
||||
ok(HeapFree(heap,0,mem1a),"HeapFree failed\n");
|
||||
} else {
|
||||
ok(HeapFree(heap,0,mem1),"HeapFree failed\n");
|
||||
}
|
||||
if(mem2a) {
|
||||
ok(HeapFree(heap,0,mem2a),"HeapFree failed\n");
|
||||
} else {
|
||||
ok(HeapFree(heap,0,mem2),"HeapFree failed\n");
|
||||
}
|
||||
|
||||
/* 0-length buffer */
|
||||
mem1 = HeapAlloc(heap, 0, 0);
|
||||
ok(mem1 != NULL, "Reserved memory\n");
|
||||
|
||||
dwSize = HeapSize(heap, 0, mem1);
|
||||
/* should work with 0-length buffer */
|
||||
ok((dwSize >= 0) && (dwSize < 0xFFFFFFFF),
|
||||
"The size of the 0-length buffer\n");
|
||||
ok(HeapFree(heap, 0, mem1), "Freed the 0-length buffer\n");
|
||||
|
||||
/* Check that HeapDestry works */
|
||||
ok(HeapDestroy(heap),"HeapDestroy failed\n");
|
||||
}
|
||||
|
||||
/* The following functions don't have tests, because either I don't know how
|
||||
to test them, or they are WinNT only, or require multiple threads.
|
||||
Since the last two issues shouldn't really stop the tests from being
|
||||
written, assume for now that it is all due to the first case
|
||||
GlobalFlags
|
||||
GlobalMemoryStatus
|
||||
GlobalMemoryStatusEx
|
||||
*/
|
||||
/* In addition, these features aren't being tested
|
||||
GMEM_DISCADABLE
|
||||
GMEM_NOCOMPACT
|
||||
*/
|
||||
static void test_Global(void)
|
||||
{
|
||||
ULONG memchunk;
|
||||
HGLOBAL mem1,mem2,mem2a,mem2b;
|
||||
UCHAR *mem2ptr;
|
||||
UINT error,i;
|
||||
memchunk=100000;
|
||||
|
||||
SetLastError(NO_ERROR);
|
||||
/* Check that a normal alloc works */
|
||||
mem1=GlobalAlloc(0,memchunk);
|
||||
ok(mem1!=NULL,"GlobalAlloc failed\n");
|
||||
if(mem1) {
|
||||
ok(GlobalSize(mem1)>=memchunk, "GlobalAlloc should return a big enough memory block\n");
|
||||
}
|
||||
|
||||
/* Check that a 'zeroing' alloc works */
|
||||
mem2=GlobalAlloc(GMEM_ZEROINIT,memchunk);
|
||||
ok(mem2!=NULL,"GlobalAlloc failed: error=%ld\n",GetLastError());
|
||||
if(mem2) {
|
||||
ok(GlobalSize(mem2)>=memchunk,"GlobalAlloc should return a big enough memory block\n");
|
||||
mem2ptr=GlobalLock(mem2);
|
||||
ok(mem2ptr==mem2,"GlobalLock should have returned the same memory as was allocated\n");
|
||||
if(mem2ptr) {
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i++) {
|
||||
if(mem2ptr[i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"GlobalAlloc should have zeroed out it's allocated memory\n");
|
||||
}
|
||||
}
|
||||
/* Check that GlobalReAlloc works */
|
||||
/* Check that we can change GMEM_FIXED to GMEM_MOVEABLE */
|
||||
mem2a=GlobalReAlloc(mem2,0,GMEM_MODIFY | GMEM_MOVEABLE);
|
||||
ok(mem2a!=NULL,"GlobalReAlloc failed to convert FIXED to MOVEABLE: error=%ld\n",GetLastError());
|
||||
if(mem2a!=NULL) {
|
||||
mem2=mem2a;
|
||||
}
|
||||
mem2ptr=GlobalLock(mem2a);
|
||||
ok(mem2ptr!=NULL && !GlobalUnlock(mem2a)&&GetLastError()==NO_ERROR,
|
||||
"Converting from FIXED to MOVEABLE didn't REALLY work\n");
|
||||
|
||||
/* Check that ReAllocing memory works as expected */
|
||||
mem2a=GlobalReAlloc(mem2,2*memchunk,GMEM_MOVEABLE | GMEM_ZEROINIT);
|
||||
ok(mem2a!=NULL,"GlobalReAlloc failed\n");
|
||||
if(mem2a) {
|
||||
ok(GlobalSize(mem2a)>=2*memchunk,"GlobalReAlloc failed\n");
|
||||
mem2ptr=GlobalLock(mem2a);
|
||||
ok(mem2ptr!=NULL,"GlobalLock Failed\n");
|
||||
if(mem2ptr) {
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i++) {
|
||||
if(mem2ptr[memchunk+i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"GlobalReAlloc should have zeroed out it's allocated memory\n");
|
||||
|
||||
/* Check that GlobalHandle works */
|
||||
mem2b=GlobalHandle(mem2ptr);
|
||||
ok(mem2b==mem2a,"GlobalHandle didn't return the correct memory handle\n");
|
||||
|
||||
/* Check that we can't discard locked memory */
|
||||
mem2b=GlobalDiscard(mem2a);
|
||||
ok(mem2b==NULL,"Discarded memory we shouldn't have\n");
|
||||
ok(!GlobalUnlock(mem2a) && GetLastError()==NO_ERROR,"GlobalUnlock Failed\n");
|
||||
}
|
||||
}
|
||||
if(mem1) {
|
||||
ok(GlobalFree(mem1)==NULL,"GlobalFree failed\n");
|
||||
}
|
||||
if(mem2a) {
|
||||
ok(GlobalFree(mem2a)==NULL,"GlobalFree failed\n");
|
||||
} else {
|
||||
ok(GlobalFree(mem2)==NULL,"GlobalFree failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* The following functions don't have tests, because either I don't know how
|
||||
to test them, or they are WinNT only, or require multiple threads.
|
||||
Since the last two issues shouldn't really stop the tests from being
|
||||
written, assume for now that it is all due to the first case
|
||||
LocalDiscard
|
||||
LocalFlags
|
||||
*/
|
||||
/* In addition, these features aren't being tested
|
||||
LMEM_DISCADABLE
|
||||
LMEM_NOCOMPACT
|
||||
*/
|
||||
static void test_Local(void)
|
||||
{
|
||||
ULONG memchunk;
|
||||
HLOCAL mem1,mem2,mem2a,mem2b;
|
||||
UCHAR *mem2ptr;
|
||||
UINT error,i;
|
||||
memchunk=100000;
|
||||
|
||||
/* Check that a normal alloc works */
|
||||
mem1=LocalAlloc(0,memchunk);
|
||||
ok(mem1!=NULL,"LocalAlloc failed: error=%ld\n",GetLastError());
|
||||
if(mem1) {
|
||||
ok(LocalSize(mem1)>=memchunk, "LocalAlloc should return a big enough memory block\n");
|
||||
}
|
||||
|
||||
/* Check that a 'zeroing' and lock alloc works */
|
||||
mem2=LocalAlloc(LMEM_ZEROINIT|LMEM_MOVEABLE,memchunk);
|
||||
ok(mem2!=NULL,"LocalAlloc failed: error=%ld\n",GetLastError());
|
||||
if(mem2) {
|
||||
ok(LocalSize(mem2)>=memchunk,"LocalAlloc should return a big enough memory block\n");
|
||||
mem2ptr=LocalLock(mem2);
|
||||
ok(mem2ptr!=NULL,"LocalLock: error=%ld\n",GetLastError());
|
||||
if(mem2ptr) {
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i++) {
|
||||
if(mem2ptr[i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"LocalAlloc should have zeroed out it's allocated memory\n");
|
||||
SetLastError(0);
|
||||
error=LocalUnlock(mem2);
|
||||
ok(error==0 && GetLastError()==NO_ERROR,
|
||||
"LocalUnlock Failed: rc=%d err=%ld\n",error,GetLastError());
|
||||
}
|
||||
}
|
||||
mem2a=LocalFree(mem2);
|
||||
ok(mem2a==NULL, "LocalFree failed: %p\n",mem2a);
|
||||
|
||||
/* Reallocate mem2 as moveable memory */
|
||||
mem2=LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,memchunk);
|
||||
ok(mem2!=NULL, "LocalAlloc failed to create moveable memory, error=%ld\n",GetLastError());
|
||||
|
||||
/* Check that ReAllocing memory works as expected */
|
||||
mem2a=LocalReAlloc(mem2,2*memchunk,LMEM_MOVEABLE | LMEM_ZEROINIT);
|
||||
ok(mem2a!=NULL,"LocalReAlloc failed, error=%ld\n",GetLastError());
|
||||
if(mem2a) {
|
||||
ok(LocalSize(mem2a)>=2*memchunk,"LocalReAlloc failed\n");
|
||||
mem2ptr=LocalLock(mem2a);
|
||||
ok(mem2ptr!=NULL,"LocalLock Failed\n");
|
||||
if(mem2ptr) {
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i++) {
|
||||
if(mem2ptr[memchunk+i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"LocalReAlloc should have zeroed out it's allocated memory\n");
|
||||
/* Check that LocalHandle works */
|
||||
mem2b=LocalHandle(mem2ptr);
|
||||
ok(mem2b==mem2a,"LocalHandle didn't return the correct memory handle\n");
|
||||
/* Check that we can't discard locked memory */
|
||||
mem2b=LocalDiscard(mem2a);
|
||||
ok(mem2b==NULL,"Discarded memory we shouldn't have\n");
|
||||
SetLastError(NO_ERROR);
|
||||
ok(!LocalUnlock(mem2a) && GetLastError()==NO_ERROR, "LocalUnlock Failed\n");
|
||||
}
|
||||
}
|
||||
if(mem1) {
|
||||
ok(LocalFree(mem1)==NULL,"LocalFree failed\n");
|
||||
}
|
||||
if(mem2a) {
|
||||
ok(LocalFree(mem2a)==NULL,"LocalFree failed\n");
|
||||
} else {
|
||||
ok(LocalFree(mem2)==NULL,"LocalFree failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* The Virtual* routines are not tested as thoroughly,
|
||||
since I don't really understand how to use them correctly :)
|
||||
The following routines are not tested at all
|
||||
VirtualAllocEx
|
||||
VirtualFreeEx
|
||||
VirtualLock
|
||||
VirtualProtect
|
||||
VirtualProtectEx
|
||||
VirtualQuery
|
||||
VirtualQueryEx
|
||||
VirtualUnlock
|
||||
And the only features (flags) being tested are
|
||||
MEM_COMMIT
|
||||
MEM_RELEASE
|
||||
PAGE_READWRITE
|
||||
Testing the rest requires using exceptions, which I really don't
|
||||
understand well
|
||||
*/
|
||||
static void test_Virtual(void)
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
ULONG memchunk;
|
||||
UCHAR *mem1;
|
||||
UINT error,i;
|
||||
|
||||
/* Retrieve the page size for this system */
|
||||
sysInfo.dwPageSize=0;
|
||||
GetSystemInfo(&sysInfo);
|
||||
ok(sysInfo.dwPageSize>0,"GetSystemInfo should return a valid page size\n");
|
||||
|
||||
/* Choose a reasonable allocation size */
|
||||
memchunk=10*sysInfo.dwPageSize;
|
||||
|
||||
/* Check that a normal alloc works */
|
||||
mem1=VirtualAlloc(NULL,memchunk,MEM_COMMIT,PAGE_READWRITE);
|
||||
ok(mem1!=NULL,"VirtualAlloc failed\n");
|
||||
if(mem1) {
|
||||
/* check that memory is initialized to 0 */
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i++) {
|
||||
if(mem1[i]!=0) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"VirtualAlloc did not initialize memory to '0's\n");
|
||||
/* Check that we can read/write to memory */
|
||||
error=0;
|
||||
for(i=0;i<memchunk;i+=100) {
|
||||
mem1[i]='a';
|
||||
if(mem1[i]!='a') {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error,"Virtual memory was not writable\n");
|
||||
}
|
||||
ok(VirtualFree(mem1,0,MEM_RELEASE),"VirtualFree failed\n");
|
||||
}
|
||||
START_TEST(alloc)
|
||||
{
|
||||
test_Heap();
|
||||
test_Global();
|
||||
test_Local();
|
||||
test_Virtual();
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
/*
|
||||
* Unit tests for atom functions
|
||||
*
|
||||
* Copyright (c) 2002 Alexandre Julliard
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
||||
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
|
||||
static const WCHAR FOOBARW[] = {'F','O','O','B','A','R',0};
|
||||
static const WCHAR _foobarW[] = {'_','f','o','o','b','a','r',0};
|
||||
|
||||
static BOOL unicode_OS;
|
||||
|
||||
static void test_add_atom(void)
|
||||
{
|
||||
ATOM atom, w_atom;
|
||||
int i;
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
atom = GlobalAddAtomA( "foobar" );
|
||||
ok( atom >= 0xc000, "bad atom id %x\n", atom );
|
||||
ok( GetLastError() == 0xdeadbeef, "GlobalAddAtomA set last error\n" );
|
||||
|
||||
/* Verify that it can be found (or not) appropriately */
|
||||
ok( GlobalFindAtomA( "foobar" ) == atom, "could not find atom foobar\n" );
|
||||
ok( GlobalFindAtomA( "FOOBAR" ) == atom, "could not find atom FOOBAR\n" );
|
||||
ok( !GlobalFindAtomA( "_foobar" ), "found _foobar\n" );
|
||||
|
||||
/* Add the same atom, specifying string as unicode; should
|
||||
* find the first one, not add a new one */
|
||||
SetLastError( 0xdeadbeef );
|
||||
w_atom = GlobalAddAtomW( foobarW );
|
||||
if (w_atom && GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
unicode_OS = TRUE;
|
||||
else
|
||||
trace("WARNING: Unicode atom APIs are not supported on this platform\n");
|
||||
|
||||
if (unicode_OS)
|
||||
{
|
||||
ok( w_atom == atom, "Unicode atom does not match ASCII\n" );
|
||||
ok( GetLastError() == 0xdeadbeef, "GlobalAddAtomW set last error\n" );
|
||||
}
|
||||
|
||||
/* Verify that it can be found (or not) appropriately via unicode name */
|
||||
if (unicode_OS)
|
||||
{
|
||||
ok( GlobalFindAtomW( foobarW ) == atom, "could not find atom foobar\n" );
|
||||
ok( GlobalFindAtomW( FOOBARW ) == atom, "could not find atom FOOBAR\n" );
|
||||
ok( !GlobalFindAtomW( _foobarW ), "found _foobar\n" );
|
||||
}
|
||||
|
||||
/* Test integer atoms
|
||||
* (0x0001 .. 0xbfff) should be valid;
|
||||
* (0xc000 .. 0xffff) should be invalid */
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ok( GlobalAddAtomA(0) == 0 && GetLastError() == 0xdeadbeef, "succeeded to add atom 0\n" );
|
||||
if (unicode_OS)
|
||||
{
|
||||
SetLastError( 0xdeadbeef );
|
||||
ok( GlobalAddAtomW(0) == 0 && GetLastError() == 0xdeadbeef, "succeeded to add atom 0\n" );
|
||||
}
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
for (i = 1; i <= 0xbfff; i++)
|
||||
{
|
||||
SetLastError( 0xdeadbeef );
|
||||
ok( GlobalAddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
|
||||
"failed to add atom %x\n", i );
|
||||
if (unicode_OS)
|
||||
{
|
||||
SetLastError( 0xdeadbeef );
|
||||
ok( GlobalAddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
|
||||
"failed to add atom %x\n", i );
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0xc000; i <= 0xffff; i++)
|
||||
{
|
||||
ok( !GlobalAddAtomA((LPCSTR)i), "succeeded adding %x\n", i );
|
||||
if (unicode_OS)
|
||||
ok( !GlobalAddAtomW((LPCWSTR)i), "succeeded adding %x\n", i );
|
||||
}
|
||||
}
|
||||
|
||||
static void test_get_atom_name(void)
|
||||
{
|
||||
char buf[10];
|
||||
WCHAR bufW[10];
|
||||
int i;
|
||||
UINT len;
|
||||
static const WCHAR resultW[] = {'f','o','o','b','a','r',0,'.','.','.'};
|
||||
|
||||
ATOM atom = GlobalAddAtomA( "foobar" );
|
||||
|
||||
/* Get the name of the atom we added above */
|
||||
memset( buf, '.', sizeof(buf) );
|
||||
len = GlobalGetAtomNameA( atom, buf, 10 );
|
||||
ok( len == strlen("foobar"), "bad length %d\n", len );
|
||||
ok( !memcmp( buf, "foobar\0...", 10 ), "bad buffer contents\n" );
|
||||
|
||||
/* Repeat, unicode-style */
|
||||
if (unicode_OS)
|
||||
{
|
||||
for (i = 0; i < 10; i++) bufW[i] = '.';
|
||||
SetLastError( 0xdeadbeef );
|
||||
len = GlobalGetAtomNameW( atom, bufW, 10 );
|
||||
ok( len && GetLastError() == 0xdeadbeef, "GlobalGetAtomNameW failed\n" );
|
||||
ok( len == lstrlenW(foobarW), "bad length %d\n", len );
|
||||
ok( !memcmp( bufW, resultW, 10*sizeof(WCHAR) ), "bad buffer contents\n" );
|
||||
}
|
||||
|
||||
/* Check error code returns */
|
||||
memset(buf, '.', 10);
|
||||
ok( !GlobalGetAtomNameA( atom, buf, 0 ), "succeeded\n" );
|
||||
ok( !memcmp( buf, "..........", 10 ), "should not touch buffer\n" );
|
||||
|
||||
if (unicode_OS)
|
||||
{
|
||||
static const WCHAR sampleW[10] = {'.','.','.','.','.','.','.','.','.','.'};
|
||||
|
||||
for (i = 0; i < 10; i++) bufW[i] = '.';
|
||||
ok( !GlobalGetAtomNameW( atom, bufW, 0 ), "succeeded\n" );
|
||||
ok( !memcmp( bufW, sampleW, 10 * sizeof(WCHAR) ), "should not touch buffer\n" );
|
||||
}
|
||||
|
||||
/* Test integer atoms */
|
||||
for (i = 0; i <= 0xbfff; i++)
|
||||
{
|
||||
memset( buf, 'a', 10 );
|
||||
len = GlobalGetAtomNameA( (ATOM)i, buf, 10 );
|
||||
if (i)
|
||||
{
|
||||
char res[20];
|
||||
ok( (len > 1) && (len < 7), "bad length %d\n", len );
|
||||
sprintf( res, "#%d", i );
|
||||
memset( res + strlen(res) + 1, 'a', 10 );
|
||||
ok( !memcmp( res, buf, 10 ), "bad buffer contents %s\n", buf );
|
||||
}
|
||||
else
|
||||
ok( !len, "bad length %d\n", len );
|
||||
}
|
||||
}
|
||||
|
||||
static void test_error_handling(void)
|
||||
{
|
||||
char buffer[260];
|
||||
WCHAR bufferW[260];
|
||||
int i;
|
||||
|
||||
memset( buffer, 'a', 256 );
|
||||
buffer[256] = 0;
|
||||
ok( !GlobalAddAtomA(buffer), "add succeeded\n" );
|
||||
ok( !GlobalFindAtomA(buffer), "find succeeded\n" );
|
||||
|
||||
if (unicode_OS)
|
||||
{
|
||||
for (i = 0; i < 256; i++) bufferW[i] = 'b';
|
||||
bufferW[256] = 0;
|
||||
ok( !GlobalAddAtomW(bufferW), "add succeeded\n" );
|
||||
ok( !GlobalFindAtomW(bufferW), "find succeeded\n" );
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(atom)
|
||||
{
|
||||
test_add_atom();
|
||||
test_get_atom_name();
|
||||
test_error_handling();
|
||||
}
|
|
@ -1,237 +0,0 @@
|
|||
/*
|
||||
* Tests for file change notification functions
|
||||
*
|
||||
* Copyright (c) 2004 Hans Leidekker
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* TODO: - security attribute changes
|
||||
* - compound filter and multiple notifications
|
||||
* - subtree notifications
|
||||
* - non-documented flags FILE_NOTIFY_CHANGE_LAST_ACCESS and
|
||||
* FILE_NOTIFY_CHANGE_CREATION
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
|
||||
static DWORD CALLBACK NotificationThread(LPVOID arg)
|
||||
{
|
||||
HANDLE change = (HANDLE) arg;
|
||||
BOOL ret = FALSE;
|
||||
DWORD status;
|
||||
|
||||
status = WaitForSingleObject(change, 100);
|
||||
|
||||
if (status == WAIT_OBJECT_0 ) {
|
||||
ret = FindNextChangeNotification(change);
|
||||
}
|
||||
|
||||
ok(FindCloseChangeNotification(change), "FindCloseChangeNotification error: %ld\n",
|
||||
GetLastError());
|
||||
|
||||
ExitThread((DWORD)ret);
|
||||
}
|
||||
|
||||
static HANDLE StartNotificationThread(LPCSTR path, BOOL subtree, DWORD flags)
|
||||
{
|
||||
HANDLE change, thread;
|
||||
DWORD threadId;
|
||||
|
||||
change = FindFirstChangeNotificationA(path, subtree, flags);
|
||||
ok(change != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %ld\n", GetLastError());
|
||||
|
||||
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NotificationThread, (LPVOID)change,
|
||||
0, &threadId);
|
||||
ok(thread != INVALID_HANDLE_VALUE, "CreateThread error: %ld\n", GetLastError());
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
static DWORD FinishNotificationThread(HANDLE thread)
|
||||
{
|
||||
DWORD status, exitcode;
|
||||
|
||||
status = WaitForSingleObject(thread, 5000);
|
||||
ok(status == WAIT_OBJECT_0, "WaitForSingleObject status %ld error %ld\n", status, GetLastError());
|
||||
|
||||
ok(GetExitCodeThread(thread, &exitcode), "Could not retrieve thread exit code\n");
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
static void test_FindFirstChangeNotification(void)
|
||||
{
|
||||
HANDLE change, file, thread;
|
||||
DWORD attributes, count;
|
||||
BOOL ret;
|
||||
|
||||
char workdir[MAX_PATH], dirname1[MAX_PATH], dirname2[MAX_PATH];
|
||||
char filename1[MAX_PATH], filename2[MAX_PATH];
|
||||
static const char prefix[] = "FCN";
|
||||
char buffer[2048];
|
||||
|
||||
/* pathetic checks */
|
||||
|
||||
change = FindFirstChangeNotificationA("not-a-file", FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
|
||||
ok(change == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND,
|
||||
"FindFirstChangeNotification error: %ld\n", GetLastError());
|
||||
|
||||
if (0) /* This documents win2k behavior. It crashes on win98. */
|
||||
{
|
||||
change = FindFirstChangeNotificationA(NULL, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
|
||||
ok(change == NULL && GetLastError() == ERROR_PATH_NOT_FOUND,
|
||||
"FindFirstChangeNotification error: %ld\n", GetLastError());
|
||||
}
|
||||
|
||||
ret = FindNextChangeNotification(NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindNextChangeNotification error: %ld\n",
|
||||
GetLastError());
|
||||
|
||||
ret = FindCloseChangeNotification(NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindCloseChangeNotification error: %ld\n",
|
||||
GetLastError());
|
||||
|
||||
ret = GetTempPathA(MAX_PATH, workdir);
|
||||
ok(ret, "GetTempPathA error: %ld\n", GetLastError());
|
||||
|
||||
lstrcatA(workdir, "testFileChangeNotification");
|
||||
|
||||
ret = CreateDirectoryA(workdir, NULL);
|
||||
ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
|
||||
|
||||
ret = GetTempFileNameA(workdir, prefix, 0, filename1);
|
||||
ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
|
||||
|
||||
file = CreateFileA(filename1, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
|
||||
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
|
||||
|
||||
/* Try to register notification for a file. win98 and win2k behave differently here */
|
||||
change = FindFirstChangeNotificationA(filename1, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
|
||||
ok(change == INVALID_HANDLE_VALUE && (GetLastError() == ERROR_DIRECTORY ||
|
||||
GetLastError() == ERROR_FILE_NOT_FOUND),
|
||||
"FindFirstChangeNotification error: %ld\n", GetLastError());
|
||||
|
||||
lstrcpyA(dirname1, filename1);
|
||||
lstrcatA(dirname1, "dir");
|
||||
|
||||
ret = CreateDirectoryA(dirname1, NULL);
|
||||
ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
|
||||
|
||||
/* What if we remove the directory we registered notification for? */
|
||||
thread = StartNotificationThread(dirname1, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
|
||||
ret = RemoveDirectoryA(dirname1);
|
||||
ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
|
||||
|
||||
/* win98 and win2k behave differently here */
|
||||
ret = FinishNotificationThread(thread);
|
||||
ok(ret || !ret, "You'll never read this\n");
|
||||
|
||||
/* functional checks */
|
||||
|
||||
/* Create a directory */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
|
||||
ret = CreateDirectoryA(dirname1, NULL);
|
||||
ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
lstrcpyA(dirname2, dirname1);
|
||||
lstrcatA(dirname2, "new");
|
||||
|
||||
/* Rename a directory */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
|
||||
ret = MoveFileA(dirname1, dirname2);
|
||||
ok(ret, "MoveFileA error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
/* Delete a directory */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
|
||||
ret = RemoveDirectoryA(dirname2);
|
||||
ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
lstrcpyA(filename2, filename1);
|
||||
lstrcatA(filename2, "new");
|
||||
|
||||
/* Rename a file */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
|
||||
ret = MoveFileA(filename1, filename2);
|
||||
ok(ret, "MoveFileA error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
/* Delete a file */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
|
||||
ret = DeleteFileA(filename2);
|
||||
ok(ret, "DeleteFileA error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
/* Create a file */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
|
||||
file = CreateFileA(filename2, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
|
||||
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
attributes = GetFileAttributesA(filename2);
|
||||
ok(attributes != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA error: %ld\n", GetLastError());
|
||||
attributes &= FILE_ATTRIBUTE_READONLY;
|
||||
|
||||
/* Change file attributes */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_ATTRIBUTES);
|
||||
ret = SetFileAttributesA(filename2, attributes);
|
||||
ok(ret, "SetFileAttributesA error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
/* Change last write time by writing to a file */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
|
||||
file = CreateFileA(filename2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
|
||||
ret = WriteFile(file, buffer, sizeof(buffer), &count, NULL);
|
||||
ok(ret && count == sizeof(buffer), "WriteFile error: %ld\n", GetLastError());
|
||||
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
/* Change file size by truncating a file */
|
||||
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_SIZE);
|
||||
file = CreateFileA(filename2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
|
||||
ret = WriteFile(file, buffer, sizeof(buffer) / 2, &count, NULL);
|
||||
ok(ret && count == sizeof(buffer) / 2, "WriteFileA error: %ld\n", GetLastError());
|
||||
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
|
||||
ok(FinishNotificationThread(thread), "Missed notification\n");
|
||||
|
||||
/* clean up */
|
||||
|
||||
ret = DeleteFileA(filename2);
|
||||
ok(ret, "DeleteFileA error: %ld\n", GetLastError());
|
||||
|
||||
ret = RemoveDirectoryA(workdir);
|
||||
ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
|
||||
}
|
||||
|
||||
START_TEST(change)
|
||||
{
|
||||
test_FindFirstChangeNotification();
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Unit tests for code page to/from unicode translations
|
||||
*
|
||||
* Copyright (c) 2002 Dmitry Timoshkov
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
|
||||
/* lstrcmpW is not supported on Win9x! */
|
||||
static int mylstrcmpW(const WCHAR* str1, const WCHAR* str2)
|
||||
{
|
||||
while (*str1 && *str1==*str2) {
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
return *str1-*str2;
|
||||
}
|
||||
|
||||
static void test_negative_source_length(void)
|
||||
{
|
||||
int len;
|
||||
char buf[10];
|
||||
WCHAR bufW[10];
|
||||
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
|
||||
|
||||
/* Test, whether any negative source length works as strlen() + 1 */
|
||||
SetLastError( 0xdeadbeef );
|
||||
memset(buf,'x',sizeof(buf));
|
||||
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -2002, buf, 10, NULL, NULL);
|
||||
ok(len == 7 && !lstrcmpA(buf, "foobar") && GetLastError() == 0xdeadbeef,
|
||||
"WideCharToMultiByte(-2002): len=%d error=%ld\n",len,GetLastError());
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
memset(bufW,'x',sizeof(bufW));
|
||||
len = MultiByteToWideChar(CP_ACP, 0, "foobar", -2002, bufW, 10);
|
||||
ok(len == 7 && !mylstrcmpW(bufW, foobarW) && GetLastError() == 0xdeadbeef,
|
||||
"MultiByteToWideChar(-2002): len=%d error=%ld\n",len,GetLastError());
|
||||
}
|
||||
|
||||
START_TEST(codepage)
|
||||
{
|
||||
test_negative_source_length();
|
||||
}
|
|
@ -1,640 +0,0 @@
|
|||
/* Unit test suite for comm functions
|
||||
*
|
||||
* Copyright 2003 Kevin Groeneveld
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char string[100];
|
||||
BOOL result;
|
||||
BOOL old_style;
|
||||
DCB dcb1, dcb2;
|
||||
COMMTIMEOUTS timeouts1, timeouts2;
|
||||
} TEST;
|
||||
|
||||
static TEST test[] =
|
||||
{
|
||||
{
|
||||
"baud=9600 parity=e data=5 stop=1 xon=on odsr=off octs=off dtr=on rts=on idsr=on",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x02, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x02, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"baud=0 parity=M data=6 stop=1.5 xon=off odsr=on octs=ON dtr=off rts=off idsr=OFF",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x03, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00000000, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x03, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"BAUD=4000000000 parity=n data=7 stop=2 to=off",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0xee6b2800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x00, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xee6b2800, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x00, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
},
|
||||
{
|
||||
"Baud=115200 Parity=O Data=8 To=On",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x0001c200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x01, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x0001c200, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x01, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
|
||||
},
|
||||
{
|
||||
"PaRiTy=s Data=7 DTR=on",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x04, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x04, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"data=4",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"data=9",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"parity=no",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"stop=0",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"stop=1.501",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"stop=3",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"to=foobar",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
" baud=9600",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"baud= 9600",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"baud=9600,data=8",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"11,n,8,1",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x0000006e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x0000006e, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"30 ,E, 5,1.5",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x0000012c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x02, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x0000012c, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x02, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"60, m, 6, 2 ",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00000258, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x03, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00000258, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x03, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"12 , o , 7 , 1",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x000004b0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x01, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x000004b0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x01, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"24,s,8,1.5",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00000960, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x04, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00000960, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x04, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"48,n,8,1,p",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x000012c0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x000012c0, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,8,1 , x ",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"19, e, 7, 1, x",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00004b00, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x02, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00004b00, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x02, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"0,M,7,1,P",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x03, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00000000, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x03, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"4000000000,O,7,1.5,X",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0xee6b2800, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x01, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xee6b2800, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x01, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,8,1 to=on",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,NO,8,1",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,4,1",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,9,1",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,8,0",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,8,3",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"96,N,8,1,K",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COM0:baud=115200",
|
||||
FALSE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx:baud=38400 data=8",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00009600, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00009600, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx :to=on stop=1.5",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
|
||||
},
|
||||
{
|
||||
"COMx: baud=12345 data=7",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00003039, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00003039, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx : xon=on odsr=off",
|
||||
TRUE, FALSE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COM0:9600,N,8,1",
|
||||
FALSE, TRUE,
|
||||
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx:9600,N,8,1",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx: 11,E,7,2",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x0000006e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x02, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x0000006e, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x02, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx :19,M,5,1",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x00004b00, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x03, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x00004b00, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x03, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
{
|
||||
"COMx : 57600,S,6,2,x",
|
||||
TRUE, TRUE,
|
||||
{ 0x00000000, 0x0000e100, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x04, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
|
||||
{ 0xffffffff, 0x0000e100, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x04, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
|
||||
},
|
||||
};
|
||||
|
||||
#define TEST_COUNT (sizeof(test) / sizeof(TEST))
|
||||
|
||||
/* This function can be useful if you are modifiying the test cases and want to
|
||||
output the contents of a DCB structure. */
|
||||
/*static print_dcb(DCB *pdcb)
|
||||
{
|
||||
printf("0x%08x, 0x%08x, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, 0x%05x, 0x%04x, 0x%04x, 0x%04x, 0x%02x, 0x%02x, 0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, 0x%04x\n",
|
||||
pdcb->DCBlength,
|
||||
pdcb->BaudRate,
|
||||
pdcb->fBinary,
|
||||
pdcb->fParity,
|
||||
pdcb->fOutxCtsFlow,
|
||||
pdcb->fOutxDsrFlow,
|
||||
pdcb->fDtrControl,
|
||||
pdcb->fDsrSensitivity,
|
||||
pdcb->fTXContinueOnXoff,
|
||||
pdcb->fOutX,
|
||||
pdcb->fInX,
|
||||
pdcb->fErrorChar,
|
||||
pdcb->fNull,
|
||||
pdcb->fRtsControl,
|
||||
pdcb->fAbortOnError,
|
||||
pdcb->fDummy2,
|
||||
pdcb->wReserved,
|
||||
pdcb->XonLim,
|
||||
pdcb->XoffLim,
|
||||
pdcb->ByteSize,
|
||||
pdcb->Parity,
|
||||
pdcb->StopBits,
|
||||
pdcb->XonChar & 0xff,
|
||||
pdcb->XoffChar & 0xff,
|
||||
pdcb->ErrorChar & 0xff,
|
||||
pdcb->EofChar & 0xff,
|
||||
pdcb->EvtChar & 0xff,
|
||||
pdcb->wReserved1 & 0xffff );
|
||||
} */
|
||||
|
||||
static void check_result(char *function, TEST *ptest, int initial_value, BOOL result)
|
||||
{
|
||||
DWORD LastError = GetLastError();
|
||||
DWORD CorrectError = (ptest->result ? 0xdeadbeef : ERROR_INVALID_PARAMETER);
|
||||
|
||||
ok(LastError == CorrectError, "%s(\"%s\"), 0x%02x: GetLastError() returned 0x%08lx, should be 0x%08lx\n", function, ptest->string, initial_value, LastError, CorrectError);
|
||||
ok(result == ptest->result, "%s(\"%s\"), 0x%02x: return value should be %s\n", function, ptest->string, initial_value, ptest->result ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
#define check_dcb_member(a,b) ok(pdcb1->a == pdcb2->a, "%s(\"%s\"), 0x%02x: "#a" is "b", should be "b"\n", function, ptest->string, initial_value, pdcb1->a, pdcb2->a)
|
||||
#define check_dcb_member2(a,c,b) if(pdcb2->a == c) { check_dcb_member(a,b); } else { ok(pdcb1->a == pdcb2->a || pdcb1->a == c, "%s(\"%s\"), 0x%02x: "#a" is "b", should be "b" or "b"\n", function, ptest->string, initial_value, pdcb1->a, pdcb2->a, c); }
|
||||
|
||||
static void check_dcb(char *function, TEST *ptest, int initial_value, DCB *pdcb1, DCB *pdcb2)
|
||||
{
|
||||
/* DCBlength is a special case since Win 9x sets it but NT does not.
|
||||
We will accept either as correct. */
|
||||
check_dcb_member2(DCBlength, (DWORD)sizeof(DCB), "%lu");
|
||||
|
||||
/* For old style control strings Win 9x does not set the next five members, NT does. */
|
||||
if(ptest->old_style && ptest->result)
|
||||
{
|
||||
check_dcb_member2(fOutxCtsFlow, ((unsigned int)initial_value & 1), "%u");
|
||||
check_dcb_member2(fDtrControl, ((unsigned int)initial_value & 3), "%u");
|
||||
check_dcb_member2(fOutX, ((unsigned int)initial_value & 1), "%u");
|
||||
check_dcb_member2(fInX, ((unsigned)initial_value & 1), "%u");
|
||||
check_dcb_member2(fRtsControl, ((unsigned)initial_value & 3), "%u");
|
||||
}
|
||||
else
|
||||
{
|
||||
check_dcb_member(fOutxCtsFlow, "%u");
|
||||
check_dcb_member(fDtrControl, "%u");
|
||||
check_dcb_member(fOutX, "%u");
|
||||
check_dcb_member(fInX, "%u");
|
||||
check_dcb_member(fRtsControl, "%u");
|
||||
}
|
||||
|
||||
if(ptest->result)
|
||||
{
|
||||
/* For the idsr=xxx parameter, NT sets fDsrSensitivity, 9x sets
|
||||
fOutxDsrFlow. */
|
||||
if(!ptest->old_style)
|
||||
{
|
||||
check_dcb_member2(fOutxDsrFlow, pdcb2->fDsrSensitivity, "%u");
|
||||
check_dcb_member2(fDsrSensitivity, pdcb2->fOutxDsrFlow, "%u");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For old style control strings Win 9x does not set the
|
||||
fOutxDsrFlow member, NT does. */
|
||||
check_dcb_member2(fOutxDsrFlow, ((unsigned int)initial_value & 1), "%u");
|
||||
check_dcb_member(fDsrSensitivity, "%u");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
check_dcb_member(fOutxDsrFlow, "%u");
|
||||
check_dcb_member(fDsrSensitivity, "%u");
|
||||
}
|
||||
|
||||
/* Check the result of the DCB members. */
|
||||
check_dcb_member(BaudRate, "%lu");
|
||||
check_dcb_member(fBinary, "%u");
|
||||
check_dcb_member(fParity, "%u");
|
||||
check_dcb_member(fTXContinueOnXoff, "%u");
|
||||
check_dcb_member(fErrorChar, "%u");
|
||||
check_dcb_member(fNull, "%u");
|
||||
check_dcb_member(fAbortOnError, "%u");
|
||||
check_dcb_member(fDummy2, "%u");
|
||||
check_dcb_member(wReserved, "%u");
|
||||
check_dcb_member(XonLim, "%u");
|
||||
check_dcb_member(XoffLim, "%u");
|
||||
check_dcb_member(ByteSize, "%u");
|
||||
check_dcb_member(Parity, "%u");
|
||||
check_dcb_member(StopBits, "%u");
|
||||
check_dcb_member(XonChar, "%d");
|
||||
check_dcb_member(XoffChar, "%d");
|
||||
check_dcb_member(ErrorChar, "%d");
|
||||
check_dcb_member(EofChar, "%d");
|
||||
check_dcb_member(EvtChar, "%d");
|
||||
check_dcb_member(wReserved1, "%u");
|
||||
}
|
||||
|
||||
#define check_timeouts_member(a) ok(ptimeouts1->a == ptimeouts2->a, "%s(\"%s\"), 0x%02x: "#a" is %lu, should be %lu\n", function, ptest->string, initial_value, ptimeouts1->a, ptimeouts2->a);
|
||||
|
||||
static void check_timeouts(char *function, TEST *ptest, int initial_value, COMMTIMEOUTS *ptimeouts1, COMMTIMEOUTS *ptimeouts2)
|
||||
{
|
||||
check_timeouts_member(ReadIntervalTimeout);
|
||||
check_timeouts_member(ReadTotalTimeoutMultiplier);
|
||||
check_timeouts_member(ReadTotalTimeoutConstant);
|
||||
check_timeouts_member(WriteTotalTimeoutMultiplier);
|
||||
check_timeouts_member(WriteTotalTimeoutConstant);
|
||||
}
|
||||
|
||||
static void test_BuildCommDCBA(TEST *ptest, int initial_value, DCB *pexpected_dcb)
|
||||
{
|
||||
BOOL result;
|
||||
DCB dcb;
|
||||
|
||||
/* set initial conditions */
|
||||
memset(&dcb, initial_value, sizeof(DCB));
|
||||
SetLastError(0xdeadbeef);
|
||||
|
||||
result = BuildCommDCBA(ptest->string, &dcb);
|
||||
|
||||
/* check results */
|
||||
check_result("BuildCommDCBA", ptest, initial_value, result);
|
||||
check_dcb("BuildCommDCBA", ptest, initial_value, &dcb, pexpected_dcb);
|
||||
}
|
||||
|
||||
static void test_BuildCommDCBAndTimeoutsA(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
|
||||
{
|
||||
BOOL result;
|
||||
DCB dcb;
|
||||
COMMTIMEOUTS timeouts;
|
||||
|
||||
/* set initial conditions */
|
||||
memset(&dcb, initial_value, sizeof(DCB));
|
||||
memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
|
||||
SetLastError(0xdeadbeef);
|
||||
|
||||
result = BuildCommDCBAndTimeoutsA(ptest->string, &dcb, &timeouts);
|
||||
|
||||
/* check results */
|
||||
check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
|
||||
check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
|
||||
check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
|
||||
}
|
||||
|
||||
static void test_BuildCommDCBW(TEST *ptest, int initial_value, DCB *pexpected_dcb)
|
||||
{
|
||||
BOOL result;
|
||||
DCB dcb;
|
||||
WCHAR wide_string[sizeof(ptest->string)];
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
|
||||
|
||||
/* set initial conditions */
|
||||
memset(&dcb, initial_value, sizeof(DCB));
|
||||
SetLastError(0xdeadbeef);
|
||||
|
||||
result = BuildCommDCBW(wide_string, &dcb);
|
||||
|
||||
if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
|
||||
/* check results */
|
||||
check_result("BuildCommDCBW", ptest, initial_value, result);
|
||||
check_dcb("BuildCommDCBW", ptest, initial_value, &dcb, pexpected_dcb);
|
||||
}
|
||||
|
||||
static void test_BuildCommDCBAndTimeoutsW(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
|
||||
{
|
||||
BOOL result;
|
||||
DCB dcb;
|
||||
COMMTIMEOUTS timeouts;
|
||||
WCHAR wide_string[sizeof(ptest->string)];
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
|
||||
|
||||
/* set initial conditions */
|
||||
memset(&dcb, initial_value, sizeof(DCB));
|
||||
memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
|
||||
SetLastError(0xdeadbeef);
|
||||
|
||||
result = BuildCommDCBAndTimeoutsW(wide_string, &dcb, &timeouts);
|
||||
|
||||
if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
|
||||
/* check results */
|
||||
check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
|
||||
check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
|
||||
check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
|
||||
}
|
||||
|
||||
static void test_BuildCommDCB(void)
|
||||
{
|
||||
char port_name[] = "COMx";
|
||||
char port = 0;
|
||||
int i;
|
||||
char *ptr;
|
||||
|
||||
/* Some of these tests require a valid COM port. This loop will try to find
|
||||
a valid port. */
|
||||
for(port_name[3] = '1'; port_name[3] <= '9'; port_name[3]++)
|
||||
{
|
||||
COMMCONFIG commconfig;
|
||||
DWORD size = sizeof(COMMCONFIG);
|
||||
|
||||
if(GetDefaultCommConfig(port_name, &commconfig, &size))
|
||||
{
|
||||
port = port_name[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!port)
|
||||
trace("Could not find a valid COM port. Some tests will be skipped.\n");
|
||||
|
||||
for(i = 0; i < TEST_COUNT; i++)
|
||||
{
|
||||
/* Check if this test case needs a valid COM port. */
|
||||
ptr = strstr(test[i].string, "COMx");
|
||||
|
||||
/* If required, substitute valid port number into device control string. */
|
||||
if(ptr)
|
||||
{
|
||||
if(port)
|
||||
ptr[3] = port;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
test_BuildCommDCBA(&test[i], 0x00, &test[i].dcb1);
|
||||
test_BuildCommDCBA(&test[i], 0xff, &test[i].dcb2);
|
||||
test_BuildCommDCBAndTimeoutsA(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
|
||||
test_BuildCommDCBAndTimeoutsA(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
|
||||
|
||||
test_BuildCommDCBW(&test[i], 0x00, &test[i].dcb1);
|
||||
test_BuildCommDCBW(&test[i], 0xff, &test[i].dcb2);
|
||||
test_BuildCommDCBAndTimeoutsW(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
|
||||
test_BuildCommDCBAndTimeoutsW(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(comm)
|
||||
{
|
||||
test_BuildCommDCB();
|
||||
}
|
|
@ -1,561 +0,0 @@
|
|||
/*
|
||||
* Unit tests for console API
|
||||
*
|
||||
* Copyright (c) 2003 Eric Pouech
|
||||
*
|
||||
* 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 "wine/test.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* DEFAULT_ATTRIB is used for all initial filling of the console.
|
||||
* all modifications are made with TEST_ATTRIB so that we could check
|
||||
* what has to be modified or not
|
||||
*/
|
||||
#define TEST_ATTRIB (BACKGROUND_BLUE | FOREGROUND_GREEN)
|
||||
#define DEFAULT_ATTRIB (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED)
|
||||
/* when filling the screen with non-blank chars, this macro defines
|
||||
* what character should be at position 'c'
|
||||
*/
|
||||
#define CONTENT(c) ('A' + (((c).Y * 17 + (c).X) % 23))
|
||||
|
||||
#define okCURSOR(hCon, c) do { \
|
||||
CONSOLE_SCREEN_BUFFER_INFO __sbi; \
|
||||
BOOL expect = GetConsoleScreenBufferInfo((hCon), &__sbi) && \
|
||||
__sbi.dwCursorPosition.X == (c).X && __sbi.dwCursorPosition.Y == (c).Y; \
|
||||
ok(expect, "Expected cursor at (%d,%d), got (%d,%d)\n", \
|
||||
(c).X, (c).Y, __sbi.dwCursorPosition.X, __sbi.dwCursorPosition.Y); \
|
||||
} while (0)
|
||||
|
||||
#define okCHAR(hCon, c, ch, attr) do { \
|
||||
char __ch; WORD __attr; DWORD __len; BOOL expect; \
|
||||
expect = ReadConsoleOutputCharacter((hCon), &__ch, 1, (c), &__len) == 1 && __len == 1 && __ch == (ch); \
|
||||
ok(expect, "At (%d,%d): expecting char '%c'/%02x got '%c'/%02x\n", (c).X, (c).Y, (ch), (ch), __ch, __ch); \
|
||||
expect = ReadConsoleOutputAttribute((hCon), &__attr, 1, (c), &__len) == 1 && __len == 1 && __attr == (attr); \
|
||||
ok(expect, "At (%d,%d): expecting attr %04x got %04x\n", (c).X, (c).Y, (attr), __attr); \
|
||||
} while (0)
|
||||
|
||||
/* FIXME: this could be optimized on a speed point of view */
|
||||
static void resetContent(HANDLE hCon, COORD sbSize, BOOL content)
|
||||
{
|
||||
COORD c;
|
||||
WORD attr = DEFAULT_ATTRIB;
|
||||
char ch;
|
||||
DWORD len;
|
||||
|
||||
for (c.X = 0; c.X < sbSize.X; c.X++)
|
||||
{
|
||||
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
|
||||
{
|
||||
ch = (content) ? CONTENT(c) : ' ';
|
||||
WriteConsoleOutputAttribute(hCon, &attr, 1, c, &len);
|
||||
WriteConsoleOutputCharacterA(hCon, &ch, 1, c, &len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void testCursor(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
COORD c;
|
||||
|
||||
c.X = c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(0, c) == 0, "No handle\n");
|
||||
ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %lu\n",
|
||||
ERROR_INVALID_HANDLE, GetLastError());
|
||||
|
||||
c.X = c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left\n");
|
||||
okCURSOR(hCon, c);
|
||||
|
||||
c.X = sbSize.X - 1;
|
||||
c.Y = sbSize.Y - 1;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in lower-right\n");
|
||||
okCURSOR(hCon, c);
|
||||
|
||||
c.X = sbSize.X;
|
||||
c.Y = sbSize.Y - 1;
|
||||
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
|
||||
ERROR_INVALID_PARAMETER, GetLastError());
|
||||
|
||||
c.X = sbSize.X - 1;
|
||||
c.Y = sbSize.Y;
|
||||
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
|
||||
ERROR_INVALID_PARAMETER, GetLastError());
|
||||
|
||||
c.X = -1;
|
||||
c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
|
||||
ERROR_INVALID_PARAMETER, GetLastError());
|
||||
|
||||
c.X = 0;
|
||||
c.Y = -1;
|
||||
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
|
||||
ERROR_INVALID_PARAMETER, GetLastError());
|
||||
}
|
||||
|
||||
static void testWriteSimple(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
COORD c;
|
||||
DWORD len;
|
||||
const char* mytest = "abcdefg";
|
||||
const int mylen = strlen(mytest);
|
||||
|
||||
/* single line write */
|
||||
c.X = c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
c.Y = 0;
|
||||
for (c.X = 0; c.X < mylen; c.X++)
|
||||
{
|
||||
okCHAR(hCon, c, mytest[c.X], TEST_ATTRIB);
|
||||
}
|
||||
|
||||
okCURSOR(hCon, c);
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
}
|
||||
|
||||
static void testWriteNotWrappedNotProcessed(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
COORD c;
|
||||
DWORD len, mode;
|
||||
char* mytest;
|
||||
int mylen;
|
||||
int ret;
|
||||
int p;
|
||||
|
||||
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, mode & ~(ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT)),
|
||||
"clearing wrap at EOL & processed output\n");
|
||||
|
||||
/* write line, wrapping disabled, buffer exceeds sb width */
|
||||
c.X = sbSize.X - 3; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
|
||||
|
||||
mytest = "123";
|
||||
|
||||
mylen = strlen(mytest);
|
||||
|
||||
ret = WriteConsole(hCon, mytest, mylen, &len, NULL);
|
||||
ok(ret != 0 && len == mylen, "Couldn't write, ret = %d, len = %ld\n", ret, len);
|
||||
c.Y = 0;
|
||||
for (p = mylen - 3; p < mylen; p++)
|
||||
{
|
||||
c.X = sbSize.X - 3 + p % 3;
|
||||
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
|
||||
}
|
||||
|
||||
c.X = 0; c.Y = 1;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
p = sbSize.X - 3 + mylen % 3;
|
||||
c.X = p; c.Y = 0;
|
||||
|
||||
/* write line, wrapping disabled, strings end on end of line */
|
||||
c.X = sbSize.X - mylen; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
}
|
||||
|
||||
static void testWriteNotWrappedProcessed(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
COORD c;
|
||||
DWORD len, mode;
|
||||
const char* mytest = "abcd\nf\tg";
|
||||
const int mylen = strlen(mytest);
|
||||
const int mylen2 = strchr(mytest, '\n') - mytest;
|
||||
int p;
|
||||
|
||||
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, (mode | ENABLE_PROCESSED_OUTPUT) & ~ENABLE_WRAP_AT_EOL_OUTPUT),
|
||||
"clearing wrap at EOL & setting processed output\n");
|
||||
|
||||
/* write line, wrapping disabled, buffer exceeds sb width */
|
||||
c.X = sbSize.X - 5; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-5\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
c.Y = 0;
|
||||
for (c.X = sbSize.X - 5; c.X < sbSize.X - 1; c.X++)
|
||||
{
|
||||
okCHAR(hCon, c, mytest[c.X - sbSize.X + 5], TEST_ATTRIB);
|
||||
}
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
c.X = 0; c.Y++;
|
||||
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
|
||||
for (c.X = 1; c.X < 8; c.X++)
|
||||
okCHAR(hCon, c, ' ', TEST_ATTRIB);
|
||||
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
|
||||
c.X++;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
okCURSOR(hCon, c);
|
||||
|
||||
/* write line, wrapping disabled, strings end on end of line */
|
||||
c.X = sbSize.X - 4; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-4\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
c.Y = 0;
|
||||
for (c.X = sbSize.X - 4; c.X < sbSize.X; c.X++)
|
||||
{
|
||||
okCHAR(hCon, c, mytest[c.X - sbSize.X + 4], TEST_ATTRIB);
|
||||
}
|
||||
c.X = 0; c.Y++;
|
||||
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
|
||||
for (c.X = 1; c.X < 8; c.X++)
|
||||
okCHAR(hCon, c, ' ', TEST_ATTRIB);
|
||||
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
|
||||
c.X++;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
okCURSOR(hCon, c);
|
||||
|
||||
/* write line, wrapping disabled, strings end after end of line */
|
||||
c.X = sbSize.X - 3; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-4\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
c.Y = 0;
|
||||
for (p = mylen2 - 3; p < mylen2; p++)
|
||||
{
|
||||
c.X = sbSize.X - 3 + p % 3;
|
||||
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
|
||||
}
|
||||
c.X = 0; c.Y = 1;
|
||||
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
|
||||
for (c.X = 1; c.X < 8; c.X++)
|
||||
okCHAR(hCon, c, ' ', TEST_ATTRIB);
|
||||
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
|
||||
c.X++;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
okCURSOR(hCon, c);
|
||||
}
|
||||
|
||||
static void testWriteWrappedNotProcessed(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
COORD c;
|
||||
DWORD len, mode;
|
||||
const char* mytest = "abcd\nf\tg";
|
||||
const int mylen = strlen(mytest);
|
||||
int p;
|
||||
|
||||
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon,(mode | ENABLE_WRAP_AT_EOL_OUTPUT) & ~(ENABLE_PROCESSED_OUTPUT)),
|
||||
"setting wrap at EOL & clearing processed output\n");
|
||||
|
||||
/* write line, wrapping enabled, buffer doesn't exceed sb width */
|
||||
c.X = sbSize.X - 9; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-9\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
c.Y = 0;
|
||||
for (p = 0; p < mylen; p++)
|
||||
{
|
||||
c.X = sbSize.X - 9 + p;
|
||||
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
|
||||
}
|
||||
c.X = sbSize.X - 9 + mylen;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
c.X = 0; c.Y = 1;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
/* write line, wrapping enabled, buffer does exceed sb width */
|
||||
c.X = sbSize.X - 3; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
|
||||
|
||||
c.Y = 1;
|
||||
c.X = mylen - 3;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
}
|
||||
|
||||
static void testWriteWrappedProcessed(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
COORD c;
|
||||
DWORD len, mode;
|
||||
const char* mytest = "abcd\nf\tg";
|
||||
const int mylen = strlen(mytest);
|
||||
int p;
|
||||
|
||||
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, mode | (ENABLE_WRAP_AT_EOL_OUTPUT|ENABLE_PROCESSED_OUTPUT)),
|
||||
"setting wrap at EOL & processed output\n");
|
||||
|
||||
/* write line, wrapping enabled, buffer doesn't exceed sb width */
|
||||
c.X = sbSize.X - 9; c.Y = 0;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-9\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
for (p = 0; p < 4; p++)
|
||||
{
|
||||
c.X = sbSize.X - 9 + p;
|
||||
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
|
||||
}
|
||||
c.X = sbSize.X - 9 + p;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
c.X = 0; c.Y++;
|
||||
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
|
||||
for (c.X = 1; c.X < 8; c.X++)
|
||||
okCHAR(hCon, c, ' ', TEST_ATTRIB);
|
||||
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
|
||||
c.X++;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
okCURSOR(hCon, c);
|
||||
|
||||
/* write line, wrapping enabled, buffer does exceed sb width */
|
||||
c.X = sbSize.X - 3; c.Y = 2;
|
||||
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
|
||||
|
||||
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
|
||||
for (p = 0; p < 3; p++)
|
||||
{
|
||||
c.X = sbSize.X - 3 + p;
|
||||
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
|
||||
}
|
||||
c.X = 0; c.Y++;
|
||||
okCHAR(hCon, c, mytest[3], TEST_ATTRIB);
|
||||
c.X++;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
|
||||
c.X = 0; c.Y++;
|
||||
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
|
||||
for (c.X = 1; c.X < 8; c.X++)
|
||||
okCHAR(hCon, c, ' ', TEST_ATTRIB);
|
||||
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
|
||||
c.X++;
|
||||
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
|
||||
okCURSOR(hCon, c);
|
||||
}
|
||||
|
||||
static void testWrite(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
/* FIXME: should in fact insure that the sb is at least 10 character wide */
|
||||
ok(SetConsoleTextAttribute(hCon, TEST_ATTRIB), "Setting default text color\n");
|
||||
resetContent(hCon, sbSize, FALSE);
|
||||
testWriteSimple(hCon, sbSize);
|
||||
resetContent(hCon, sbSize, FALSE);
|
||||
testWriteNotWrappedNotProcessed(hCon, sbSize);
|
||||
resetContent(hCon, sbSize, FALSE);
|
||||
testWriteNotWrappedProcessed(hCon, sbSize);
|
||||
resetContent(hCon, sbSize, FALSE);
|
||||
testWriteWrappedNotProcessed(hCon, sbSize);
|
||||
resetContent(hCon, sbSize, FALSE);
|
||||
testWriteWrappedProcessed(hCon, sbSize);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void testScroll(HANDLE hCon, COORD sbSize)
|
||||
{
|
||||
SMALL_RECT scroll, clip;
|
||||
COORD dst, c, tc;
|
||||
CHAR_INFO ci;
|
||||
|
||||
#define W 11
|
||||
#define H 7
|
||||
|
||||
/* no clipping, src & dst rect don't overlap */
|
||||
resetContent(hCon, sbSize, TRUE);
|
||||
|
||||
#define IN_SRECT(r,c) ((r).Left <= (c).X && (c).X <= (r).Right && (r).Top <= (c).Y && (c).Y <= (r).Bottom)
|
||||
#define IN_SRECT2(r,d,c) ((d).X <= (c).X && (c).X <= (d).X + (r).Right - (r).Left && (d).Y <= (c).Y && (c).Y <= (d).Y + (r).Bottom - (r).Top)
|
||||
|
||||
scroll.Left = 0;
|
||||
scroll.Right = W - 1;
|
||||
scroll.Top = 0;
|
||||
scroll.Bottom = H - 1;
|
||||
dst.X = W + 3;
|
||||
dst.Y = H + 3;
|
||||
ci.Char.UnicodeChar = '#';
|
||||
ci.Attributes = TEST_ATTRIB;
|
||||
|
||||
clip.Left = 0;
|
||||
clip.Right = sbSize.X - 1;
|
||||
clip.Top = 0;
|
||||
clip.Bottom = sbSize.Y - 1;
|
||||
|
||||
ok(ScrollConsoleScreenBuffer(hCon, &scroll, NULL, dst, &ci), "Scrolling SB\n");
|
||||
|
||||
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
|
||||
{
|
||||
for (c.X = 0; c.X < sbSize.X; c.X++)
|
||||
{
|
||||
if (IN_SRECT2(scroll, dst, c) && IN_SRECT(clip, c))
|
||||
{
|
||||
tc.X = c.X - dst.X;
|
||||
tc.Y = c.Y - dst.Y;
|
||||
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
|
||||
}
|
||||
else if (IN_SRECT(scroll, c) && IN_SRECT(clip, c))
|
||||
okCHAR(hCon, c, '#', TEST_ATTRIB);
|
||||
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
|
||||
}
|
||||
}
|
||||
|
||||
/* no clipping, src & dst rect do overlap */
|
||||
resetContent(hCon, sbSize, TRUE);
|
||||
|
||||
scroll.Left = 0;
|
||||
scroll.Right = W - 1;
|
||||
scroll.Top = 0;
|
||||
scroll.Bottom = H - 1;
|
||||
dst.X = W /2;
|
||||
dst.Y = H / 2;
|
||||
ci.Char.UnicodeChar = '#';
|
||||
ci.Attributes = TEST_ATTRIB;
|
||||
|
||||
clip.Left = 0;
|
||||
clip.Right = sbSize.X - 1;
|
||||
clip.Top = 0;
|
||||
clip.Bottom = sbSize.Y - 1;
|
||||
|
||||
ok(ScrollConsoleScreenBuffer(hCon, &scroll, NULL, dst, &ci), "Scrolling SB\n");
|
||||
|
||||
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
|
||||
{
|
||||
for (c.X = 0; c.X < sbSize.X; c.X++)
|
||||
{
|
||||
if (dst.X <= c.X && c.X < dst.X + W && dst.Y <= c.Y && c.Y < dst.Y + H)
|
||||
{
|
||||
tc.X = c.X - dst.X;
|
||||
tc.Y = c.Y - dst.Y;
|
||||
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
|
||||
}
|
||||
else if (c.X < W && c.Y < H) okCHAR(hCon, c, '#', TEST_ATTRIB);
|
||||
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
|
||||
}
|
||||
}
|
||||
|
||||
/* clipping, src & dst rect don't overlap */
|
||||
resetContent(hCon, sbSize, TRUE);
|
||||
|
||||
scroll.Left = 0;
|
||||
scroll.Right = W - 1;
|
||||
scroll.Top = 0;
|
||||
scroll.Bottom = H - 1;
|
||||
dst.X = W + 3;
|
||||
dst.Y = H + 3;
|
||||
ci.Char.UnicodeChar = '#';
|
||||
ci.Attributes = TEST_ATTRIB;
|
||||
|
||||
clip.Left = W / 2;
|
||||
clip.Right = min(W + W / 2, sbSize.X - 1);
|
||||
clip.Top = H / 2;
|
||||
clip.Bottom = min(H + H / 2, sbSize.Y - 1);
|
||||
|
||||
ok(ScrollConsoleScreenBuffer(hCon, &scroll, &clip, dst, &ci), "Scrolling SB\n");
|
||||
|
||||
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
|
||||
{
|
||||
for (c.X = 0; c.X < sbSize.X; c.X++)
|
||||
{
|
||||
if (IN_SRECT2(scroll, dst, c) && IN_SRECT(clip, c))
|
||||
{
|
||||
tc.X = c.X - dst.X;
|
||||
tc.Y = c.Y - dst.Y;
|
||||
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
|
||||
}
|
||||
else if (IN_SRECT(scroll, c) && IN_SRECT(clip, c))
|
||||
okCHAR(hCon, c, '#', TEST_ATTRIB);
|
||||
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
|
||||
}
|
||||
}
|
||||
|
||||
/* clipping, src & dst rect do overlap */
|
||||
resetContent(hCon, sbSize, TRUE);
|
||||
|
||||
scroll.Left = 0;
|
||||
scroll.Right = W - 1;
|
||||
scroll.Top = 0;
|
||||
scroll.Bottom = H - 1;
|
||||
dst.X = W / 2 - 3;
|
||||
dst.Y = H / 2 - 3;
|
||||
ci.Char.UnicodeChar = '#';
|
||||
ci.Attributes = TEST_ATTRIB;
|
||||
|
||||
clip.Left = W / 2;
|
||||
clip.Right = min(W + W / 2, sbSize.X - 1);
|
||||
clip.Top = H / 2;
|
||||
clip.Bottom = min(H + H / 2, sbSize.Y - 1);
|
||||
|
||||
ok(ScrollConsoleScreenBuffer(hCon, &scroll, &clip, dst, &ci), "Scrolling SB\n");
|
||||
|
||||
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
|
||||
{
|
||||
for (c.X = 0; c.X < sbSize.X; c.X++)
|
||||
{
|
||||
if (IN_SRECT2(scroll, dst, c) && IN_SRECT(clip, c))
|
||||
{
|
||||
tc.X = c.X - dst.X;
|
||||
tc.Y = c.Y - dst.Y;
|
||||
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
|
||||
}
|
||||
else if (IN_SRECT(scroll, c) && IN_SRECT(clip, c))
|
||||
okCHAR(hCon, c, '#', TEST_ATTRIB);
|
||||
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
START_TEST(console)
|
||||
{
|
||||
HANDLE hConIn, hConOut;
|
||||
BOOL ret;
|
||||
CONSOLE_SCREEN_BUFFER_INFO sbi;
|
||||
|
||||
/* be sure we have a clean console (and that's our own)
|
||||
* FIXME: this will make the test fail (currently) if we don't run
|
||||
* under X11
|
||||
* Another solution would be to rerun the test under wineconsole with
|
||||
* the curses backend
|
||||
*/
|
||||
|
||||
hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
|
||||
/* first, we need to be sure we're attached to a console */
|
||||
if (hConIn == INVALID_HANDLE_VALUE || hConOut == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/* we're not attached to a console, let's do it */
|
||||
AllocConsole();
|
||||
hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
}
|
||||
/* now verify everything's ok */
|
||||
ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
|
||||
ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
|
||||
|
||||
ok(ret = GetConsoleScreenBufferInfo(hConOut, &sbi), "Getting sb info\n");
|
||||
if (!ret) return;
|
||||
|
||||
/* Non interactive tests */
|
||||
testCursor(hConOut, sbi.dwSize);
|
||||
/* will test wrapped (on/off) & processed (on/off) strings output */
|
||||
testWrite(hConOut, sbi.dwSize);
|
||||
/* will test line scrolling at the bottom of the screen */
|
||||
/* testBottomScroll(); */
|
||||
/* will test all the scrolling operations */
|
||||
/* this one is disabled for now, Wine's result are way too bad */
|
||||
/* testScroll(hCon, sbi.dwSize); */
|
||||
/* will test sb creation / modification... */
|
||||
/* testScreenBuffer() */
|
||||
|
||||
/* still to be done: events generation, access rights & access on objects */
|
||||
}
|
|
@ -1,342 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for directory functions.
|
||||
*
|
||||
* Copyright 2002 Dmitry Timoshkov
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
||||
/* If you change something in these tests, please do the same
|
||||
* for GetSystemDirectory tests.
|
||||
*/
|
||||
static void test_GetWindowsDirectoryA(void)
|
||||
{
|
||||
UINT len, len_with_null;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
len_with_null = GetWindowsDirectoryA(NULL, 0);
|
||||
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len_with_null = GetWindowsDirectoryA(buf, 1);
|
||||
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetWindowsDirectoryA(buf, len_with_null - 1);
|
||||
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetWindowsDirectoryA(buf, len_with_null);
|
||||
ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer\n");
|
||||
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
||||
ok(len == len_with_null-1, "GetWindowsDirectoryA returned %d, expected %d\n",
|
||||
len, len_with_null-1);
|
||||
}
|
||||
|
||||
static void test_GetWindowsDirectoryW(void)
|
||||
{
|
||||
UINT len, len_with_null;
|
||||
WCHAR buf[MAX_PATH];
|
||||
static const WCHAR fooW[] = {'f','o','o',0};
|
||||
|
||||
len_with_null = GetWindowsDirectoryW(NULL, 0);
|
||||
if (len_with_null==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetWindowsDirectoryW(buf, 1);
|
||||
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetWindowsDirectoryW(buf, len_with_null - 1);
|
||||
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetWindowsDirectoryW(buf, len_with_null);
|
||||
ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n");
|
||||
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
||||
ok(len == len_with_null-1, "GetWindowsDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null-1);
|
||||
}
|
||||
|
||||
|
||||
/* If you change something in these tests, please do the same
|
||||
* for GetWindowsDirectory tests.
|
||||
*/
|
||||
static void test_GetSystemDirectoryA(void)
|
||||
{
|
||||
UINT len, len_with_null;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
len_with_null = GetSystemDirectoryA(NULL, 0);
|
||||
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetSystemDirectoryA(buf, 1);
|
||||
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetSystemDirectoryA(buf, len_with_null - 1);
|
||||
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetSystemDirectoryA(buf, len_with_null);
|
||||
ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer\n");
|
||||
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
||||
ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null-1);
|
||||
}
|
||||
|
||||
static void test_GetSystemDirectoryW(void)
|
||||
{
|
||||
UINT len, len_with_null;
|
||||
WCHAR buf[MAX_PATH];
|
||||
static const WCHAR fooW[] = {'f','o','o',0};
|
||||
|
||||
len_with_null = GetSystemDirectoryW(NULL, 0);
|
||||
if (len_with_null==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetSystemDirectoryW(buf, 1);
|
||||
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetSystemDirectoryW(buf, len_with_null - 1);
|
||||
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
|
||||
ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetSystemDirectoryW(buf, len_with_null);
|
||||
ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n");
|
||||
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
||||
ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d\n",
|
||||
len, len_with_null-1);
|
||||
}
|
||||
|
||||
static void test_CreateDirectoryA(void)
|
||||
{
|
||||
char tmpdir[MAX_PATH];
|
||||
BOOL ret;
|
||||
|
||||
ret = CreateDirectoryA(NULL, NULL);
|
||||
ok(ret == FALSE && (GetLastError() == ERROR_PATH_NOT_FOUND ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER),
|
||||
"CreateDirectoryA(NULL,NULL): ret=%d error=%ld\n",ret,GetLastError());
|
||||
|
||||
ret = CreateDirectoryA("", NULL);
|
||||
ok(ret == FALSE && (GetLastError() == ERROR_BAD_PATHNAME ||
|
||||
GetLastError() == ERROR_PATH_NOT_FOUND),
|
||||
"CreateDirectoryA(\"\",NULL): ret=%d error=%ld\n",ret,GetLastError());
|
||||
|
||||
ret = GetSystemDirectoryA(tmpdir, MAX_PATH);
|
||||
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
|
||||
|
||||
ret = SetCurrentDirectoryA(tmpdir);
|
||||
ok(ret == TRUE, "could not chdir to the System directory\n");
|
||||
|
||||
ret = CreateDirectoryA(".", NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
|
||||
|
||||
ret = CreateDirectoryA("..", NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
|
||||
|
||||
GetTempPathA(MAX_PATH, tmpdir);
|
||||
tmpdir[3] = 0; /* truncate the path */
|
||||
ret = CreateDirectoryA(tmpdir, NULL);
|
||||
ok(ret == FALSE && (GetLastError() == ERROR_ALREADY_EXISTS ||
|
||||
GetLastError() == ERROR_ACCESS_DENIED),
|
||||
"CreateDirectoryA(drive_root): ret=%d error=%ld\n",ret,GetLastError());
|
||||
|
||||
GetTempPathA(MAX_PATH, tmpdir);
|
||||
lstrcatA(tmpdir, "Please Remove Me");
|
||||
ret = CreateDirectoryA(tmpdir, NULL);
|
||||
ok(ret == TRUE, "CreateDirectoryA should always succeed\n");
|
||||
|
||||
ret = CreateDirectoryA(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
|
||||
|
||||
ret = RemoveDirectoryA(tmpdir);
|
||||
ok(ret == TRUE, "RemoveDirectoryA should always succeed\n");
|
||||
|
||||
lstrcatA(tmpdir, "?");
|
||||
ret = CreateDirectoryA(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"CreateDirectoryA with ? wildcard name should fail, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
ret = RemoveDirectoryA(tmpdir);
|
||||
|
||||
tmpdir[lstrlenA(tmpdir) - 1] = '*';
|
||||
ret = CreateDirectoryA(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"CreateDirectoryA with * wildcard name should fail, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
ret = RemoveDirectoryA(tmpdir);
|
||||
}
|
||||
|
||||
static void test_CreateDirectoryW(void)
|
||||
{
|
||||
WCHAR tmpdir[MAX_PATH];
|
||||
BOOL ret;
|
||||
static const WCHAR empty_strW[] = { 0 };
|
||||
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
|
||||
static const WCHAR dotW[] = {'.',0};
|
||||
static const WCHAR dotdotW[] = {'.','.',0};
|
||||
static const WCHAR questionW[] = {'?',0};
|
||||
|
||||
ret = CreateDirectoryW(NULL, NULL);
|
||||
if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create NULL path\n");
|
||||
|
||||
ret = CreateDirectoryW(empty_strW, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create empty path\n");
|
||||
|
||||
ret = GetSystemDirectoryW(tmpdir, MAX_PATH);
|
||||
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
|
||||
|
||||
ret = SetCurrentDirectoryW(tmpdir);
|
||||
ok(ret == TRUE, "could not chdir to the System directory\n");
|
||||
|
||||
ret = CreateDirectoryW(dotW, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
|
||||
|
||||
ret = CreateDirectoryW(dotdotW, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
|
||||
|
||||
GetTempPathW(MAX_PATH, tmpdir);
|
||||
tmpdir[3] = 0; /* truncate the path */
|
||||
ret = CreateDirectoryW(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ACCESS_DENIED, "should deny access to the drive root\n");
|
||||
|
||||
GetTempPathW(MAX_PATH, tmpdir);
|
||||
lstrcatW(tmpdir, tmp_dir_name);
|
||||
ret = CreateDirectoryW(tmpdir, NULL);
|
||||
ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
|
||||
|
||||
ret = CreateDirectoryW(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
|
||||
|
||||
ret = RemoveDirectoryW(tmpdir);
|
||||
ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
|
||||
|
||||
lstrcatW(tmpdir, questionW);
|
||||
ret = CreateDirectoryW(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
ret = RemoveDirectoryW(tmpdir);
|
||||
|
||||
tmpdir[lstrlenW(tmpdir) - 1] = '*';
|
||||
ret = CreateDirectoryW(tmpdir, NULL);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
ret = RemoveDirectoryW(tmpdir);
|
||||
}
|
||||
|
||||
static void test_RemoveDirectoryA(void)
|
||||
{
|
||||
char tmpdir[MAX_PATH];
|
||||
BOOL ret;
|
||||
|
||||
GetTempPathA(MAX_PATH, tmpdir);
|
||||
lstrcatA(tmpdir, "Please Remove Me");
|
||||
ret = CreateDirectoryA(tmpdir, NULL);
|
||||
ok(ret == TRUE, "CreateDirectoryA should always succeed\n");
|
||||
|
||||
ret = RemoveDirectoryA(tmpdir);
|
||||
ok(ret == TRUE, "RemoveDirectoryA should always succeed\n");
|
||||
|
||||
lstrcatA(tmpdir, "?");
|
||||
ret = RemoveDirectoryA(tmpdir);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"RemoveDirectoryA with ? wildcard name should fail with error 183, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
|
||||
tmpdir[lstrlenA(tmpdir) - 1] = '*';
|
||||
ret = RemoveDirectoryA(tmpdir);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"RemoveDirectoryA with * wildcard name should fail with error 183, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
}
|
||||
|
||||
static void test_RemoveDirectoryW(void)
|
||||
{
|
||||
WCHAR tmpdir[MAX_PATH];
|
||||
BOOL ret;
|
||||
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
|
||||
static const WCHAR questionW[] = {'?',0};
|
||||
|
||||
GetTempPathW(MAX_PATH, tmpdir);
|
||||
lstrcatW(tmpdir, tmp_dir_name);
|
||||
ret = CreateDirectoryW(tmpdir, NULL);
|
||||
if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
|
||||
ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
|
||||
|
||||
ret = RemoveDirectoryW(tmpdir);
|
||||
ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
|
||||
|
||||
lstrcatW(tmpdir, questionW);
|
||||
ret = RemoveDirectoryW(tmpdir);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
|
||||
tmpdir[lstrlenW(tmpdir) - 1] = '*';
|
||||
ret = RemoveDirectoryW(tmpdir);
|
||||
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld\n",
|
||||
ret ? " True" : "False", GetLastError());
|
||||
}
|
||||
|
||||
START_TEST(directory)
|
||||
{
|
||||
test_GetWindowsDirectoryA();
|
||||
test_GetWindowsDirectoryW();
|
||||
|
||||
test_GetSystemDirectoryA();
|
||||
test_GetSystemDirectoryW();
|
||||
|
||||
test_CreateDirectoryA();
|
||||
test_CreateDirectoryW();
|
||||
|
||||
test_RemoveDirectoryA();
|
||||
test_RemoveDirectoryW();
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for drive functions.
|
||||
*
|
||||
* Copyright 2002 Dmitry Timoshkov
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
||||
void test_GetDriveTypeA(void)
|
||||
{
|
||||
char drive[] = "?:\\";
|
||||
DWORD logical_drives;
|
||||
UINT type;
|
||||
|
||||
logical_drives = GetLogicalDrives();
|
||||
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
|
||||
|
||||
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
|
||||
{
|
||||
type = GetDriveTypeA(drive);
|
||||
ok(type > 0 && type <= 6, "not a valid drive %c: type %u\n", drive[0], type);
|
||||
|
||||
if (!(logical_drives & 1))
|
||||
ok(type == DRIVE_NO_ROOT_DIR,
|
||||
"GetDriveTypeA should return DRIVE_NO_ROOT_DIR for inexistant drive %c: but not %u\n",
|
||||
drive[0], type);
|
||||
|
||||
logical_drives >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void test_GetDriveTypeW(void)
|
||||
{
|
||||
WCHAR drive[] = {'?',':','\\',0};
|
||||
DWORD logical_drives;
|
||||
UINT type;
|
||||
|
||||
logical_drives = GetLogicalDrives();
|
||||
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
|
||||
|
||||
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
|
||||
{
|
||||
type = GetDriveTypeW(drive);
|
||||
if (type == DRIVE_UNKNOWN && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
/* Must be Win9x which doesn't support the Unicode functions */
|
||||
return;
|
||||
}
|
||||
ok(type > 0 && type <= 6, "not a valid drive %c: type %u\n", drive[0], type);
|
||||
|
||||
if (!(logical_drives & 1))
|
||||
ok(type == DRIVE_NO_ROOT_DIR,
|
||||
"GetDriveTypeW should return DRIVE_NO_ROOT_DIR for inexistant drive %c: but not %u\n",
|
||||
drive[0], type);
|
||||
|
||||
logical_drives >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void test_GetDiskFreeSpaceA(void)
|
||||
{
|
||||
BOOL ret;
|
||||
DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
|
||||
char drive[] = "?:\\";
|
||||
DWORD logical_drives;
|
||||
|
||||
ret = GetDiskFreeSpaceA(NULL, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
|
||||
|
||||
ret = GetDiskFreeSpaceA("", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_NAME),
|
||||
"GetDiskFreeSpaceA(\"\"): ret=%d GetLastError=%ld\n",
|
||||
ret, GetLastError());
|
||||
|
||||
ret = GetDiskFreeSpaceA("\\", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
|
||||
|
||||
ret = GetDiskFreeSpaceA("/", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
|
||||
|
||||
logical_drives = GetLogicalDrives();
|
||||
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
|
||||
|
||||
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
|
||||
{
|
||||
/* Skip floppy drives because NT pops up a MessageBox if no
|
||||
* floppy is present
|
||||
*/
|
||||
if (GetDriveTypeA(drive)!=DRIVE_REMOVABLE)
|
||||
{
|
||||
ret = GetDiskFreeSpaceA(drive, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
if (!(logical_drives & 1))
|
||||
ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_DRIVE),
|
||||
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
|
||||
drive, ret, GetLastError());
|
||||
else
|
||||
ok(ret ||
|
||||
(!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
|
||||
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
|
||||
drive, ret, GetLastError());
|
||||
}
|
||||
logical_drives >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void test_GetDiskFreeSpaceW(void)
|
||||
{
|
||||
BOOL ret;
|
||||
DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
|
||||
WCHAR drive[] = {'?',':','\\',0};
|
||||
DWORD logical_drives;
|
||||
static const WCHAR empty_pathW[] = { 0 };
|
||||
static const WCHAR root_pathW[] = { '\\', 0 };
|
||||
static const WCHAR unix_style_root_pathW[] = { '/', 0 };
|
||||
|
||||
ret = GetDiskFreeSpaceW(NULL, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
if (ret == 0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
/* Must be Win9x which doesn't support the Unicode functions */
|
||||
return;
|
||||
}
|
||||
ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
|
||||
|
||||
ret = GetDiskFreeSpaceW(empty_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
|
||||
"GetDiskFreeSpaceW(\"\"): ret=%d GetLastError=%ld\n",
|
||||
ret, GetLastError());
|
||||
|
||||
ret = GetDiskFreeSpaceW(root_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(ret, "GetDiskFreeSpaceW(\"\") error %ld\n", GetLastError());
|
||||
|
||||
ret = GetDiskFreeSpaceW(unix_style_root_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
|
||||
|
||||
logical_drives = GetLogicalDrives();
|
||||
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
|
||||
|
||||
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
|
||||
{
|
||||
/* Skip floppy drives because NT4 pops up a MessageBox if no floppy is present */
|
||||
if (GetDriveTypeW(drive)!=DRIVE_REMOVABLE)
|
||||
{
|
||||
ret = GetDiskFreeSpaceW(drive, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
|
||||
if (!(logical_drives & 1))
|
||||
ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
|
||||
"GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
|
||||
drive[0], ret, GetLastError());
|
||||
else
|
||||
ok(ret || GetLastError() == ERROR_NOT_READY,
|
||||
"GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
|
||||
drive[0], ret, GetLastError());
|
||||
}
|
||||
logical_drives >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(drive)
|
||||
{
|
||||
test_GetDriveTypeA();
|
||||
test_GetDriveTypeW();
|
||||
|
||||
test_GetDiskFreeSpaceA();
|
||||
test_GetDiskFreeSpaceW();
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for environment functions.
|
||||
*
|
||||
* Copyright 2002 Dmitry Timoshkov
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
||||
static void test_GetSetEnvironmentVariableA(void)
|
||||
{
|
||||
char buf[256];
|
||||
BOOL ret;
|
||||
DWORD ret_size;
|
||||
static const char name[] = "SomeWildName";
|
||||
static const char name_cased[] = "sOMEwILDnAME";
|
||||
static const char value[] = "SomeWildValue";
|
||||
|
||||
ret = SetEnvironmentVariableA(name, value);
|
||||
ok(ret == TRUE,
|
||||
"unexpected error in SetEnvironmentVariableA, GetLastError=%ld\n",
|
||||
GetLastError());
|
||||
|
||||
/* Try to retrieve the environment variable we just set */
|
||||
ret_size = GetEnvironmentVariableA(name, NULL, 0);
|
||||
ok(ret_size == strlen(value) + 1,
|
||||
"should return length with terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value));
|
||||
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
|
||||
ok(ret_size == strlen(value) + 1,
|
||||
"should return length with terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
|
||||
ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
|
||||
ok(ret_size == strlen(value),
|
||||
"should return length without terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
|
||||
ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
|
||||
ok(ret_size == strlen(value),
|
||||
"should return length without terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
/* Remove that environment variable */
|
||||
ret = SetEnvironmentVariableA(name_cased, NULL);
|
||||
ok(ret == TRUE, "should erase existing variable\n");
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
|
||||
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
|
||||
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
|
||||
/* Check behavior of SetEnvironmentVariableA(name, "") */
|
||||
ret = SetEnvironmentVariableA(name, value);
|
||||
ok(ret == TRUE,
|
||||
"unexpected error in SetEnvironmentVariableA, GetLastError=%ld\n",
|
||||
GetLastError());
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
|
||||
ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
|
||||
ok(ret_size == strlen(value),
|
||||
"should return length without terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
ret = SetEnvironmentVariableA(name_cased, "");
|
||||
ok(ret == TRUE,
|
||||
"should not fail with empty value but GetLastError=%ld\n", GetLastError());
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
SetLastError(0);
|
||||
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
|
||||
ok(ret_size == 0 &&
|
||||
((GetLastError() == 0 && lstrcmpA(buf, "") == 0) ||
|
||||
(GetLastError() == ERROR_ENVVAR_NOT_FOUND)),
|
||||
"%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%ld GetLastError=%ld and buf=%s\n",
|
||||
name, ret_size, GetLastError(), buf);
|
||||
|
||||
/* Test the limits */
|
||||
ret_size = GetEnvironmentVariableA(NULL, NULL, 0);
|
||||
ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
|
||||
ret_size = GetEnvironmentVariableA(NULL, buf, lstrlenA(value) + 1);
|
||||
ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
|
||||
ret_size = GetEnvironmentVariableA("", buf, lstrlenA(value) + 1);
|
||||
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
}
|
||||
|
||||
static void test_GetSetEnvironmentVariableW(void)
|
||||
{
|
||||
WCHAR buf[256];
|
||||
BOOL ret;
|
||||
DWORD ret_size;
|
||||
static const WCHAR name[] = {'S','o','m','e','W','i','l','d','N','a','m','e',0};
|
||||
static const WCHAR value[] = {'S','o','m','e','W','i','l','d','V','a','l','u','e',0};
|
||||
static const WCHAR name_cased[] = {'s','O','M','E','w','I','L','D','n','A','M','E',0};
|
||||
static const WCHAR empty_strW[] = { 0 };
|
||||
static const WCHAR fooW[] = {'f','o','o',0};
|
||||
|
||||
ret = SetEnvironmentVariableW(name, value);
|
||||
if (ret == FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
/* Must be Win9x which doesn't support the Unicode functions */
|
||||
return;
|
||||
}
|
||||
ok(ret == TRUE,
|
||||
"unexpected error in SetEnvironmentVariableW, GetLastError=%ld\n",
|
||||
GetLastError());
|
||||
|
||||
/* Try to retrieve the environment variable we just set */
|
||||
ret_size = GetEnvironmentVariableW(name, NULL, 0);
|
||||
ok(ret_size == lstrlenW(value) + 1,
|
||||
"should return length with terminating 0 ret_size=%ld\n",
|
||||
ret_size);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value));
|
||||
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
|
||||
|
||||
ok(ret_size == lstrlenW(value) + 1,
|
||||
"should return length with terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
|
||||
ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
|
||||
ok(ret_size == lstrlenW(value),
|
||||
"should return length without terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
ret_size = GetEnvironmentVariableW(name_cased, buf, lstrlenW(value) + 1);
|
||||
ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
|
||||
ok(ret_size == lstrlenW(value),
|
||||
"should return length without terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
/* Remove that environment variable */
|
||||
ret = SetEnvironmentVariableW(name_cased, NULL);
|
||||
ok(ret == TRUE, "should erase existing variable\n");
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
|
||||
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
|
||||
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
|
||||
/* Check behavior of SetEnvironmentVariableW(name, "") */
|
||||
ret = SetEnvironmentVariableW(name, value);
|
||||
ok(ret == TRUE,
|
||||
"unexpected error in SetEnvironmentVariableW, GetLastError=%ld\n",
|
||||
GetLastError());
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
|
||||
ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
|
||||
ok(ret_size == lstrlenW(value),
|
||||
"should return length without terminating 0 ret_size=%ld\n", ret_size);
|
||||
|
||||
ret = SetEnvironmentVariableW(name_cased, empty_strW);
|
||||
ok(ret == TRUE, "should not fail with empty value but GetLastError=%ld\n", GetLastError());
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
|
||||
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
ok(lstrcmpW(buf, empty_strW) == 0, "should copy an empty string\n");
|
||||
|
||||
/* Test the limits */
|
||||
ret_size = GetEnvironmentVariableW(NULL, NULL, 0);
|
||||
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
|
||||
ret_size = GetEnvironmentVariableW(NULL, buf, lstrlenW(value) + 1);
|
||||
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
|
||||
"should not find variable but ret_size=%ld GetLastError=%ld\n",
|
||||
ret_size, GetLastError());
|
||||
|
||||
ret = SetEnvironmentVariableW(NULL, NULL);
|
||||
ok(ret == FALSE && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
|
||||
"should fail with NULL, NULL but ret=%d and GetLastError=%ld\n",
|
||||
ret, GetLastError());
|
||||
}
|
||||
|
||||
START_TEST(environ)
|
||||
{
|
||||
test_GetSetEnvironmentVariableA();
|
||||
test_GetSetEnvironmentVariableW();
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,226 +0,0 @@
|
|||
/* Unit test suite for FormatMessageA
|
||||
*
|
||||
* Copyright 2002 Mike McCormack for CodeWeavers
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
/* #define ok(cond,failstr) if(!(cond)) {printf("line %d : %s\n",__LINE__,failstr);exit(1);} */
|
||||
|
||||
DWORD doit(DWORD flags, LPCVOID src, DWORD msg_id, DWORD lang_id,
|
||||
LPSTR out, DWORD outsize, ... )
|
||||
{
|
||||
va_list list;
|
||||
DWORD r;
|
||||
|
||||
va_start(list, outsize);
|
||||
r = FormatMessageA(flags, src, msg_id,
|
||||
lang_id, out, outsize, &list);
|
||||
va_end(list);
|
||||
return r;
|
||||
}
|
||||
|
||||
void test_message_from_string(void)
|
||||
{
|
||||
CHAR out[0x100] = {0};
|
||||
DWORD r;
|
||||
static const WCHAR szwTest[] = { 't','e','s','t',0};
|
||||
|
||||
/* the basics */
|
||||
r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR),NULL);
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* using the format feature */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!s!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), "test");
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* no format */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), "test");
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* two pieces */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1%2", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), "te","st");
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* three pieces */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1%3%2%1", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), "t","s","e");
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* s doesn't seem to work in format strings */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%!s!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), "test");
|
||||
ok(!strcmp("!s!", out),"failed out=[%s]\n",out);
|
||||
ok(r==3,"failed: r=%ld\n",r);
|
||||
|
||||
/* S is unicode */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!S!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), szwTest);
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* as characters */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!c!%2!c!%3!c!%1!c!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 't','e','s');
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* some numbers */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!d!%2!d!%3!d!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 1,2,3);
|
||||
ok(!strcmp("123", out),"failed out=[%s]\n",out);
|
||||
ok(r==3,"failed: r=%ld\n",r);
|
||||
|
||||
/* a single digit with some spacing */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4d!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 1);
|
||||
ok(!strcmp(" 1", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* a single digit, left justified */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!-4d!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 1);
|
||||
ok(!strcmp("1 ", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* two digit decimal number */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4d!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 11);
|
||||
ok(!strcmp(" 11", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* a hex number */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4x!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 11);
|
||||
ok(!strcmp(" b", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* a hex number, upper case */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4X!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 11);
|
||||
ok(!strcmp(" B", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* a hex number, upper case, left justified */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!-4X!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 11);
|
||||
ok(!strcmp("B ", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* a long hex number, upper case */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4X!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 0x1ab);
|
||||
ok(!strcmp(" 1AB", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* two percent... */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, " %%%% ", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp(" %% ", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* periods are special cases */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, " %.%. %1!d!", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR), 0x1ab);
|
||||
ok(!strcmp(" .. 427", out),"failed out=[%s]\n",out);
|
||||
ok(r==7,"failed: r=%ld\n",r);
|
||||
|
||||
/* %0 ends the line */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "test%0test", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("test", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* %! prints an exclaimation */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "yah%!%0 ", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("yah!", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* %space */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "% % ", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp(" ", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "hi\n", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("hi\r\n", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* carriage return line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "hi\r\n", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("hi\r\n", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* carriage return line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "\r", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("\r\n", out),"failed out=[%s]\n",out);
|
||||
ok(r==2,"failed: r=%ld\n",r);
|
||||
|
||||
/* carriage return line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING, "\r\r\n", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("\r\n\r\n", out),"failed out=[%s]\n",out);
|
||||
ok(r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* change of pace... test the low byte of dwflags */
|
||||
/* line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\n", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("hi ", out) || !strcmp("hi\r\n", out),"failed out=[%s]\n",out);
|
||||
ok(r==3 || r==4,"failed: r=%ld\n",r);
|
||||
|
||||
/* carriage return line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\r\n", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp("hi ", out),"failed out=[%s]\n",out);
|
||||
ok(r==3,"failed: r=%ld\n",r);
|
||||
|
||||
/* carriage return line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp(" ", out),"failed out=[%s]\n",out);
|
||||
ok(r==1,"failed: r=%ld\n",r);
|
||||
|
||||
/* carriage return line feed */
|
||||
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r\r\n", 0,
|
||||
0, out, sizeof(out)/sizeof(CHAR));
|
||||
ok(!strcmp(" ", out),"failed out=[%s]\n",out);
|
||||
ok(r==2,"failed: r=%ld\n",r);
|
||||
}
|
||||
|
||||
START_TEST(format_msg)
|
||||
{
|
||||
test_message_from_string();
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for heap functions
|
||||
*
|
||||
* Copyright 2003 Dimitrie O. Paun
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
START_TEST(heap)
|
||||
{
|
||||
void *mem;
|
||||
HGLOBAL gbl;
|
||||
SIZE_T size;
|
||||
|
||||
/* Heap*() functions */
|
||||
mem = HeapAlloc(GetProcessHeap(), 0, 0);
|
||||
ok(mem != NULL, "memory not allocated for size 0\n");
|
||||
|
||||
mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10);
|
||||
ok(mem == NULL, "memory allocated by HeapReAlloc\n");
|
||||
|
||||
/* Global*() functions */
|
||||
gbl = GlobalAlloc(GMEM_MOVEABLE, 0);
|
||||
ok(gbl != NULL, "global memory not allocated for size 0\n");
|
||||
|
||||
gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE);
|
||||
ok(gbl != NULL, "Can't realloc global memory\n");
|
||||
size = GlobalSize(gbl);
|
||||
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
|
||||
|
||||
todo_wine
|
||||
{
|
||||
gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
|
||||
ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
|
||||
}
|
||||
|
||||
size = GlobalSize(gbl);
|
||||
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
|
||||
ok(GlobalFree(gbl) == NULL, "Memory not freed\n");
|
||||
size = GlobalSize(gbl);
|
||||
ok(size == 0, "Memory should have been freed, size=%ld\n", size);
|
||||
|
||||
gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE);
|
||||
ok(gbl == NULL, "global realloc allocated memory\n");
|
||||
|
||||
/* Local*() functions */
|
||||
gbl = LocalAlloc(GMEM_MOVEABLE, 0);
|
||||
ok(gbl != NULL, "local memory not allocated for size 0\n");
|
||||
|
||||
gbl = LocalReAlloc(gbl, 10, GMEM_MOVEABLE);
|
||||
ok(gbl != NULL, "Can't realloc local memory\n");
|
||||
size = LocalSize(gbl);
|
||||
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
|
||||
|
||||
todo_wine
|
||||
{
|
||||
gbl = LocalReAlloc(gbl, 0, GMEM_MOVEABLE);
|
||||
ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
|
||||
}
|
||||
|
||||
size = LocalSize(gbl);
|
||||
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
|
||||
ok(LocalFree(gbl) == NULL, "Memory not freed\n");
|
||||
size = LocalSize(gbl);
|
||||
ok(size == 0, "Memory should have been freed, size=%ld\n", size);
|
||||
|
||||
gbl = LocalReAlloc(0, 10, GMEM_MOVEABLE);
|
||||
ok(gbl == NULL, "local realloc allocated memory\n");
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,330 +0,0 @@
|
|||
/*
|
||||
* Mailslot regression test
|
||||
*
|
||||
* Copyright 2003 Mike McCormack
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
|
||||
#ifndef STANDALONE
|
||||
#include "wine/test.h"
|
||||
#else
|
||||
#define START_TEST(name) main(int argc, char **argv)
|
||||
|
||||
#define ok(cond,str) do{ if(!(cond)) printf("line %d: %s\n",__LINE__,str); }while (0)
|
||||
#define todo_wine
|
||||
|
||||
#endif
|
||||
|
||||
static const char szmspath[] = "\\\\.\\mailslot\\wine_mailslot_test";
|
||||
|
||||
static int mailslot_test()
|
||||
{
|
||||
HANDLE hSlot, hSlot2, hWriter, hWriter2;
|
||||
unsigned char buffer[16];
|
||||
DWORD count, dwMax, dwNext, dwMsgCount, dwTimeout;
|
||||
|
||||
/* sanity check on GetMailslotInfo */
|
||||
dwMax = dwNext = dwMsgCount = dwTimeout = 0;
|
||||
ok( !GetMailslotInfo( INVALID_HANDLE_VALUE, &dwMax, &dwNext,
|
||||
&dwMsgCount, &dwTimeout ), "getmailslotinfo succeeded\n");
|
||||
|
||||
/* open a mailslot that doesn't exist */
|
||||
hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter == INVALID_HANDLE_VALUE, "non-existing mailslot\n");
|
||||
|
||||
/* open a mailslot without the right name */
|
||||
hSlot = CreateMailslot( "blah", 0, 0, NULL );
|
||||
ok( hSlot == INVALID_HANDLE_VALUE,
|
||||
"Created mailslot with invalid name\n");
|
||||
todo_wine
|
||||
{
|
||||
ok( GetLastError() == ERROR_INVALID_NAME,
|
||||
"error should be ERROR_INVALID_NAME\n");
|
||||
}
|
||||
|
||||
/* open a mailslot with a null name */
|
||||
hSlot = CreateMailslot( NULL, 0, 0, NULL );
|
||||
ok( hSlot == INVALID_HANDLE_VALUE,
|
||||
"Created mailslot with invalid name\n");
|
||||
todo_wine
|
||||
{
|
||||
ok( GetLastError() == ERROR_PATH_NOT_FOUND,
|
||||
"error should be ERROR_PATH_NOT_FOUND\n");
|
||||
}
|
||||
|
||||
todo_wine
|
||||
{
|
||||
/* valid open, but with wacky parameters ... then check them */
|
||||
hSlot = CreateMailslot( szmspath, -1, -1, NULL );
|
||||
ok( hSlot != INVALID_HANDLE_VALUE , "mailslot with valid name failed\n");
|
||||
dwMax = dwNext = dwMsgCount = dwTimeout = 0;
|
||||
ok( GetMailslotInfo( hSlot, &dwMax, &dwNext, &dwMsgCount, &dwTimeout ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwMax == -1, "dwMax incorrect\n");
|
||||
ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
|
||||
}
|
||||
ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
|
||||
todo_wine
|
||||
{
|
||||
ok( dwTimeout == -1, "dwTimeout incorrect\n");
|
||||
ok( GetMailslotInfo( hSlot, NULL, NULL, NULL, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( CloseHandle(hSlot), "failed to close mailslot\n");
|
||||
}
|
||||
|
||||
todo_wine
|
||||
{
|
||||
/* now open it for real */
|
||||
hSlot = CreateMailslot( szmspath, 0, 0, NULL );
|
||||
ok( hSlot != INVALID_HANDLE_VALUE , "valid mailslot failed\n");
|
||||
}
|
||||
|
||||
/* try and read/write to it */
|
||||
count = 0;
|
||||
memset(buffer, 0, sizeof buffer);
|
||||
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"slot read\n");
|
||||
ok( !WriteFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"slot write\n");
|
||||
|
||||
/* now try and openthe client, but with the wrong sharing mode */
|
||||
hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
|
||||
0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter == INVALID_HANDLE_VALUE, "bad sharing mode\n");
|
||||
todo_wine
|
||||
{
|
||||
ok( GetLastError() == ERROR_SHARING_VIOLATION,
|
||||
"error should be ERROR_SHARING_VIOLATION\n");
|
||||
|
||||
/* now open the client with the correct sharing mode */
|
||||
hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter != INVALID_HANDLE_VALUE, "existing mailslot\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* opening a client should make no difference to
|
||||
* whether we can read or write the mailslot
|
||||
*/
|
||||
ok( !ReadFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
|
||||
"slot read\n");
|
||||
ok( !WriteFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
|
||||
"slot write\n");
|
||||
|
||||
/*
|
||||
* we can't read from this client,
|
||||
* but we should be able to write to it
|
||||
*/
|
||||
ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
|
||||
"can read client\n");
|
||||
todo_wine
|
||||
{
|
||||
ok( WriteFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
|
||||
"can't write client\n");
|
||||
}
|
||||
ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
|
||||
"can read client\n");
|
||||
|
||||
/*
|
||||
* seeing as there's something in the slot,
|
||||
* we should be able to read it once
|
||||
*/
|
||||
todo_wine
|
||||
{
|
||||
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"slot read\n");
|
||||
ok( count == (sizeof buffer/2), "short read\n" );
|
||||
}
|
||||
|
||||
/* but not again */
|
||||
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"slot read\n");
|
||||
|
||||
/* now try open another writer... should fail */
|
||||
hWriter2 = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter2 == INVALID_HANDLE_VALUE, "two writers\n");
|
||||
|
||||
/* now try open another as a reader ... also fails */
|
||||
hWriter2 = CreateFile(szmspath, GENERIC_READ,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter2 == INVALID_HANDLE_VALUE, "writer + reader\n");
|
||||
|
||||
/* now try open another as a writer ... still fails */
|
||||
hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter2 == INVALID_HANDLE_VALUE, "writer\n");
|
||||
|
||||
/* now open another one */
|
||||
hSlot2 = CreateMailslot( szmspath, 0, 0, NULL );
|
||||
ok( hSlot2 == INVALID_HANDLE_VALUE , "opened two mailslots\n");
|
||||
|
||||
todo_wine
|
||||
{
|
||||
/* close the client again */
|
||||
ok( CloseHandle( hWriter ), "closing the client\n");
|
||||
|
||||
/*
|
||||
* now try reopen it with slightly different permissions ...
|
||||
* shared writing
|
||||
*/
|
||||
hWriter = CreateFile(szmspath, GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter != INVALID_HANDLE_VALUE, "sharing writer\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* now try open another as a writer ...
|
||||
* but don't share with the first ... fail
|
||||
*/
|
||||
hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter2 == INVALID_HANDLE_VALUE, "greedy writer succeeded\n");
|
||||
|
||||
todo_wine
|
||||
{
|
||||
/* now try open another as a writer ... and share with the first */
|
||||
hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
ok( hWriter2 != INVALID_HANDLE_VALUE, "2nd sharing writer\n");
|
||||
|
||||
/* check the mailslot info */
|
||||
dwMax = dwNext = dwMsgCount = dwTimeout = 0;
|
||||
ok( GetMailslotInfo( hSlot, &dwMax, &dwNext, &dwMsgCount, &dwTimeout ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
|
||||
}
|
||||
ok( dwMax == 0, "dwMax incorrect\n");
|
||||
ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
|
||||
ok( dwTimeout == 0, "dwTimeout incorrect\n");
|
||||
|
||||
/* check there's still no data */
|
||||
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL), "slot read\n");
|
||||
|
||||
/* write two messages */
|
||||
todo_wine
|
||||
{
|
||||
buffer[0] = 'a';
|
||||
ok( WriteFile( hWriter, buffer, 1, &count, NULL), "1st write failed\n");
|
||||
|
||||
/* check the mailslot info */
|
||||
dwNext = dwMsgCount = 0;
|
||||
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwNext == 1, "dwNext incorrect\n");
|
||||
ok( dwMsgCount == 1, "dwMsgCount incorrect\n");
|
||||
|
||||
buffer[0] = 'b';
|
||||
buffer[1] = 'c';
|
||||
ok( WriteFile( hWriter2, buffer, 2, &count, NULL), "2nd write failed\n");
|
||||
|
||||
/* check the mailslot info */
|
||||
dwNext = dwMsgCount = 0;
|
||||
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwNext == 1, "dwNext incorrect\n");
|
||||
ok( dwMsgCount == 2, "dwMsgCount incorrect\n");
|
||||
|
||||
/* write a 3rd message with zero size */
|
||||
ok( WriteFile( hWriter2, buffer, 0, &count, NULL), "3rd write failed\n");
|
||||
|
||||
/* check the mailslot info */
|
||||
dwNext = dwMsgCount = 0;
|
||||
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwNext == 1, "dwNext incorrect\n");
|
||||
ok( dwMsgCount == 3, "dwMsgCount incorrect\n");
|
||||
|
||||
buffer[0]=buffer[1]=0;
|
||||
|
||||
/*
|
||||
* then check that they come out with the correct order and size,
|
||||
* then the slot is empty
|
||||
*/
|
||||
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"1st slot read failed\n");
|
||||
ok( count == 1, "failed to get 1st message\n");
|
||||
ok( buffer[0] == 'a', "1st message wrong\n");
|
||||
|
||||
/* check the mailslot info */
|
||||
dwNext = dwMsgCount = 0;
|
||||
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwNext == 2, "dwNext incorrect\n");
|
||||
ok( dwMsgCount == 2, "dwMsgCount incorrect\n");
|
||||
|
||||
/* read the second message */
|
||||
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"2nd slot read failed\n");
|
||||
ok( count == 2, "failed to get 2nd message\n");
|
||||
ok( ( buffer[0] == 'b' ) && ( buffer[1] == 'c' ), "2nd message wrong\n");
|
||||
|
||||
/* check the mailslot info */
|
||||
dwNext = dwMsgCount = 0;
|
||||
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
}
|
||||
ok( dwNext == 0, "dwNext incorrect\n");
|
||||
todo_wine
|
||||
{
|
||||
ok( dwMsgCount == 1, "dwMsgCount incorrect\n");
|
||||
|
||||
/* read the 3rd (zero length) message */
|
||||
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"3rd slot read failed\n");
|
||||
}
|
||||
ok( count == 0, "failed to get 3rd message\n");
|
||||
|
||||
/*
|
||||
* now there should be no more messages
|
||||
* check the mailslot info
|
||||
*/
|
||||
todo_wine
|
||||
{
|
||||
dwNext = dwMsgCount = 0;
|
||||
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
|
||||
"getmailslotinfo failed\n");
|
||||
ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
|
||||
}
|
||||
ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
|
||||
|
||||
/* check that reads fail */
|
||||
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
|
||||
"3rd slot read succeeded\n");
|
||||
|
||||
/* finally close the mailslot and its client */
|
||||
todo_wine
|
||||
{
|
||||
ok( CloseHandle( hWriter2 ), "closing 2nd client\n");
|
||||
ok( CloseHandle( hWriter ), "closing the client\n");
|
||||
ok( CloseHandle( hSlot ), "closing the mailslot\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
START_TEST(mailslot)
|
||||
{
|
||||
mailslot_test();
|
||||
}
|
|
@ -1,924 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for Get*PathNamesA and (Get|Set)CurrentDirectoryA.
|
||||
*
|
||||
* Copyright 2002 Geoffrey Hausheer
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winerror.h"
|
||||
#include "winnls.h"
|
||||
|
||||
#define HAS_TRAIL_SLASH_A(string) (string[lstrlenA(string)-1]=='\\')
|
||||
|
||||
#define LONGFILE "Long File test.path"
|
||||
#define SHORTFILE "pathtest.pth"
|
||||
#define SHORTDIR "shortdir"
|
||||
#define LONGDIR "Long Directory"
|
||||
#define NONFILE_SHORT "noexist.pth"
|
||||
#define NONFILE_LONG "Non Existent File"
|
||||
#define NONDIR_SHORT "notadir"
|
||||
#define NONDIR_LONG "Non Existent Directory"
|
||||
|
||||
#define NOT_A_VALID_DRIVE '@'
|
||||
|
||||
/* the following characters don't work well with GetFullPathNameA
|
||||
in Win98. I don't know if this is a FAT thing, or if it is an OS thing
|
||||
but I don't test these characters now.
|
||||
NOTE: Win2k allows GetFullPathNameA to work with them though
|
||||
|<>"
|
||||
*/
|
||||
static const CHAR funny_chars[]="!@#$%^&*()=+{}[],?'`";
|
||||
static const CHAR is_char_ok[] ="11111110111111111011";
|
||||
|
||||
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR,LPSTR,DWORD);
|
||||
|
||||
/* a structure to deal with wine todos somewhat cleanly */
|
||||
typedef struct {
|
||||
DWORD shortlen;
|
||||
DWORD shorterror;
|
||||
DWORD s2llen;
|
||||
DWORD s2lerror;
|
||||
DWORD longlen;
|
||||
DWORD longerror;
|
||||
} SLpassfail;
|
||||
|
||||
/* function that tests GetFullPathNameA, GetShortPathNameA,GetLongPathNameA */
|
||||
/* NOTE: the passfail structure is used to allow cutomizeable todo checking
|
||||
for wine. It is not very pretty, but it sure beats duplicating this
|
||||
function lots of times
|
||||
*/
|
||||
static void test_ValidPathA(CHAR *curdir, CHAR *subdir, CHAR *filename,
|
||||
CHAR *shortstr, SLpassfail *passfail, CHAR *errstr) {
|
||||
CHAR tmpstr[MAX_PATH],
|
||||
fullpath[MAX_PATH], /*full path to the file (not short/long) */
|
||||
subpath[MAX_PATH], /*relative path to the file */
|
||||
fullpathshort[MAX_PATH], /*absolue path to the file (short format) */
|
||||
fullpathlong[MAX_PATH], /*absolute path to the file (long format) */
|
||||
curdirshort[MAX_PATH], /*absolute path to the current dir (short) */
|
||||
curdirlong[MAX_PATH]; /*absolute path to the current dir (long) */
|
||||
LPSTR strptr; /*ptr to the filename portion of the path */
|
||||
DWORD len;
|
||||
/* if passfail is NULL, we can perform all checks within this function,
|
||||
otherwise, we will return the relevant data in the passfail struct, so
|
||||
we must initialize it first
|
||||
*/
|
||||
if(passfail!=NULL) {
|
||||
passfail->shortlen=-1;passfail->s2llen=-1;passfail->longlen=-1;
|
||||
passfail->shorterror=0;passfail->s2lerror=0;passfail->longerror=0;
|
||||
}
|
||||
/* GetLongPathNameA is only supported on Win2k+ and Win98+ */
|
||||
if(pGetLongPathNameA) {
|
||||
ok((len=pGetLongPathNameA(curdir,curdirlong,MAX_PATH)),
|
||||
"%s: GetLongPathNameA failed\n",errstr);
|
||||
/*GetLongPathNameA can return a trailing '\\' but shouldn't do so here */
|
||||
ok(! HAS_TRAIL_SLASH_A(curdirlong),
|
||||
"%s: GetLongPathNameA should not have a trailing \\\n",errstr);
|
||||
}
|
||||
ok((len=GetShortPathNameA(curdir,curdirshort,MAX_PATH)),
|
||||
"%s: GetShortPathNameA failed\n",errstr);
|
||||
/*GetShortPathNameA can return a trailing '\\' but shouldn't do so here */
|
||||
ok(! HAS_TRAIL_SLASH_A(curdirshort),
|
||||
"%s: GetShortPathNameA should not have a trailing \\\n",errstr);
|
||||
/* build relative and absolute paths from inputs */
|
||||
if(lstrlenA(subdir)) {
|
||||
sprintf(subpath,"%s\\%s",subdir,filename);
|
||||
} else {
|
||||
lstrcpyA(subpath,filename);
|
||||
}
|
||||
sprintf(fullpath,"%s\\%s",curdir,subpath);
|
||||
sprintf(fullpathshort,"%s\\%s",curdirshort,subpath);
|
||||
sprintf(fullpathlong,"%s\\%s",curdirlong,subpath);
|
||||
/* Test GetFullPathNameA functionality */
|
||||
len=GetFullPathNameA(subpath,MAX_PATH,tmpstr,&strptr);
|
||||
ok(len, "GetFullPathNameA failed for: '%s'\n",subpath);
|
||||
if(HAS_TRAIL_SLASH_A(subpath)) {
|
||||
ok(strptr==NULL,
|
||||
"%s: GetFullPathNameA should not return a filename ptr\n",errstr);
|
||||
ok(lstrcmpiA(fullpath,tmpstr)==0,
|
||||
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
|
||||
errstr,tmpstr,fullpath);
|
||||
} else {
|
||||
ok(lstrcmpiA(strptr,filename)==0,
|
||||
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
|
||||
errstr,strptr,filename);
|
||||
ok(lstrcmpiA(fullpath,tmpstr)==0,
|
||||
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
|
||||
errstr,tmpstr,fullpath);
|
||||
}
|
||||
/* Test GetShortPathNameA functionality */
|
||||
SetLastError(0);
|
||||
len=GetShortPathNameA(fullpathshort,shortstr,MAX_PATH);
|
||||
if(passfail==NULL) {
|
||||
ok(len, "%s: GetShortPathNameA failed\n",errstr);
|
||||
} else {
|
||||
passfail->shortlen=len;
|
||||
passfail->shorterror=GetLastError();
|
||||
}
|
||||
/* Test GetLongPathNameA functionality
|
||||
We test both conversion from GetFullPathNameA and from GetShortPathNameA
|
||||
*/
|
||||
if(pGetLongPathNameA) {
|
||||
if(len!=0) {
|
||||
SetLastError(0);
|
||||
len=pGetLongPathNameA(shortstr,tmpstr,MAX_PATH);
|
||||
if(passfail==NULL) {
|
||||
ok(len,
|
||||
"%s: GetLongPathNameA failed during Short->Long conversion\n", errstr);
|
||||
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
|
||||
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
|
||||
errstr,tmpstr,fullpathlong);
|
||||
} else {
|
||||
passfail->s2llen=len;
|
||||
passfail->s2lerror=GetLastError();
|
||||
}
|
||||
}
|
||||
SetLastError(0);
|
||||
len=pGetLongPathNameA(fullpath,tmpstr,MAX_PATH);
|
||||
if(passfail==NULL) {
|
||||
ok(len, "%s: GetLongPathNameA failed\n",errstr);
|
||||
if(HAS_TRAIL_SLASH_A(fullpath)) {
|
||||
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
|
||||
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
|
||||
errstr,tmpstr,fullpathlong);
|
||||
} else {
|
||||
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
|
||||
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
|
||||
errstr,tmpstr,fullpathlong);
|
||||
}
|
||||
} else {
|
||||
passfail->longlen=len;
|
||||
passfail->longerror=GetLastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* split path into leading directory, and 8.3 filename */
|
||||
static void test_SplitShortPathA(CHAR *path,CHAR *dir,CHAR *eight,CHAR *three) {
|
||||
int done,error;
|
||||
int ext,fil;
|
||||
int len,i;
|
||||
len=lstrlenA(path);
|
||||
ext=len; fil=len; done=0; error=0;
|
||||
/* walk backwards over path looking for '.' or '\\' separators */
|
||||
for(i=len-1;(i>=0) && (!done);i--) {
|
||||
if(path[i]=='.')
|
||||
if(ext!=len) error=1; else ext=i;
|
||||
else if(path[i]=='\\') {
|
||||
if(i==len-1) {
|
||||
error=1;
|
||||
} else {
|
||||
fil=i;
|
||||
done=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check that we didn't find a trailing '\\' or multiple '.' */
|
||||
ok(!error,"Illegal file found in 8.3 path '%s'\n",path);
|
||||
/* Separate dir, root, and extension */
|
||||
if(ext!=len) lstrcpyA(three,path+ext+1); else lstrcpyA(three,"");
|
||||
if(fil!=len) {
|
||||
lstrcpynA(eight,path+fil+1,ext-fil);
|
||||
lstrcpynA(dir,path,fil+1);
|
||||
} else {
|
||||
lstrcpynA(eight,path,ext+1);
|
||||
lstrcpyA(dir,"");
|
||||
}
|
||||
/* Validate that root and extension really are 8.3 */
|
||||
ok(lstrlenA(eight)<=8 && lstrlenA(three)<=3,
|
||||
"GetShortPathNAmeA did not return an 8.3 path\n");
|
||||
}
|
||||
|
||||
/* Check that GetShortPathNameA returns a valid 8.3 path */
|
||||
static void test_LongtoShortA(CHAR *teststr,CHAR *goodstr,
|
||||
CHAR *ext,CHAR *errstr) {
|
||||
CHAR dir[MAX_PATH],eight[MAX_PATH],three[MAX_PATH];
|
||||
|
||||
test_SplitShortPathA(teststr,dir,eight,three);
|
||||
ok(lstrcmpiA(dir,goodstr)==0,
|
||||
"GetShortPathNameA returned '%s' instead of '%s'\n",dir,goodstr);
|
||||
ok(lstrcmpiA(three,ext)==0,
|
||||
"GetShortPathNameA returned '%s' with incorrect extension\n",three);
|
||||
}
|
||||
|
||||
/* Test that Get(Short|Long|Full)PathNameA work correctly with interesting
|
||||
characters in the filename.
|
||||
'valid' indicates whether this would be an allowed filename
|
||||
'todo' indicates that wine doesn't get this right yet.
|
||||
NOTE: We always call this routine with a non-existent filename, so
|
||||
Get(Short|Long)PathNameA should never pass, but GetFullPathNameA
|
||||
should.
|
||||
*/
|
||||
static void test_FunnyChars(CHAR *curdir,CHAR *filename, INT valid,CHAR *errstr)
|
||||
{
|
||||
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH];
|
||||
SLpassfail passfail;
|
||||
|
||||
test_ValidPathA(curdir,"",filename,tmpstr,&passfail,errstr);
|
||||
if(valid) {
|
||||
sprintf(tmpstr1,"%s\\%s",curdir,filename);
|
||||
ok((passfail.shortlen==0 &&
|
||||
(passfail.shorterror==ERROR_FILE_NOT_FOUND || passfail.shorterror==ERROR_PATH_NOT_FOUND || !passfail.shorterror)) ||
|
||||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
||||
"%s: GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
|
||||
errstr,passfail.shortlen,passfail.shorterror,tmpstr);
|
||||
} else {
|
||||
ok(passfail.shortlen==0 &&
|
||||
(passfail.shorterror==ERROR_INVALID_NAME || passfail.shorterror==ERROR_FILE_NOT_FOUND || !passfail.shorterror),
|
||||
"%s: GetShortPathA should have failed len=%ld, error=%ld\n",
|
||||
errstr,passfail.shortlen,passfail.shorterror);
|
||||
}
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
if(valid) {
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"%s: GetLongPathA returned %ld and not %d\n",
|
||||
errstr,passfail.longerror,ERROR_FILE_NOT_FOUND);
|
||||
} else {
|
||||
ok(passfail.longerror==ERROR_INVALID_NAME ||
|
||||
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"%s: GetLongPathA returned %ld and not %d or %d'\n",
|
||||
errstr, passfail.longerror,ERROR_INVALID_NAME,ERROR_FILE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Routine to test that SetCurrentDirectory behaves as expected. */
|
||||
static void test_setdir(CHAR *olddir,CHAR *newdir,
|
||||
CHAR *cmprstr, INT pass,CHAR *errstr)
|
||||
{
|
||||
CHAR tmppath[MAX_PATH], *dirptr;
|
||||
DWORD val,len,chklen;
|
||||
|
||||
val=SetCurrentDirectoryA(newdir);
|
||||
len=GetCurrentDirectoryA(MAX_PATH,tmppath);
|
||||
/* if 'pass' then the SetDirectoryA was supposed to pass */
|
||||
if(pass) {
|
||||
dirptr=(cmprstr==NULL) ? newdir : cmprstr;
|
||||
chklen=lstrlenA(dirptr);
|
||||
ok(val,"%s: SetCurrentDirectoryA failed\n",errstr);
|
||||
ok(len==chklen,
|
||||
"%s: SetCurrentDirectory did not change the directory, though it passed\n",
|
||||
errstr);
|
||||
ok(lstrcmpiA(dirptr,tmppath)==0,
|
||||
"%s: SetCurrentDirectory did not change the directory, though it passed\n",
|
||||
errstr);
|
||||
ok(SetCurrentDirectoryA(olddir),
|
||||
"%s: Couldn't set directory to it's original value\n",errstr);
|
||||
} else {
|
||||
/* else thest that it fails correctly */
|
||||
chklen=lstrlenA(olddir);
|
||||
ok(val==0,
|
||||
"%s: SetCurrentDirectoryA passed when it should have failed\n",errstr);
|
||||
ok(len==chklen,
|
||||
"%s: SetCurrentDirectory changed the directory, though it failed\n",
|
||||
errstr);
|
||||
ok(lstrcmpiA(olddir,tmppath)==0,
|
||||
"%s: SetCurrentDirectory changed the directory, though it failed\n",
|
||||
errstr);
|
||||
}
|
||||
}
|
||||
static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
|
||||
{
|
||||
CHAR tmppath[MAX_PATH], /*path to TEMP */
|
||||
tmpstr[MAX_PATH],
|
||||
tmpstr1[MAX_PATH];
|
||||
DWORD len,len1,drives;
|
||||
INT id;
|
||||
HANDLE hndl;
|
||||
|
||||
*curDrive = *otherDrive = NOT_A_VALID_DRIVE;
|
||||
|
||||
/* Get the current drive letter */
|
||||
if( GetCurrentDirectoryA( MAX_PATH, tmpstr))
|
||||
*curDrive = tmpstr[0];
|
||||
else
|
||||
trace( "Unable to discover current drive, some tests will not be conducted.\n");
|
||||
|
||||
/* Test GetTempPathA */
|
||||
len=GetTempPathA(MAX_PATH,tmppath);
|
||||
ok(len!=0 && len < MAX_PATH,"GetTempPathA failed\n");
|
||||
ok(HAS_TRAIL_SLASH_A(tmppath),
|
||||
"GetTempPathA returned a path that did not end in '\\'\n");
|
||||
lstrcpyA(tmpstr,"aaaaaaaa");
|
||||
len1=GetTempPathA(len,tmpstr);
|
||||
ok(len1==len+1,
|
||||
"GetTempPathA should return string length %ld instead of %ld\n",len+1,len1);
|
||||
|
||||
/* Test GetTmpFileNameA
|
||||
The only test we do here is whether GetTempFileNameA passes or not.
|
||||
We do not thoroughly test this function yet (specifically, whether
|
||||
it behaves correctly when 'unique' is non zero)
|
||||
*/
|
||||
ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
|
||||
sprintf(tmpstr,"pat%.4x.tmp",id & 0xffff);
|
||||
sprintf(tmpstr1,"pat%x.tmp",id & 0xffff);
|
||||
ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
|
||||
lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
|
||||
"GetTempPath returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
|
||||
newdir,tmpstr,tmpstr1,id);
|
||||
|
||||
/* Find first valid drive letter that is neither newdir[0] nor curDrive */
|
||||
drives = GetLogicalDrives() & ~(1<<(newdir[0]-'A'));
|
||||
if( *curDrive != NOT_A_VALID_DRIVE)
|
||||
drives &= ~(1<<(*curDrive-'A'));
|
||||
if( drives)
|
||||
for( *otherDrive='A'; (drives & 1) == 0; drives>>=1, (*otherDrive)++);
|
||||
else
|
||||
trace( "Could not find alternative drive, some tests will not be conducted.\n");
|
||||
|
||||
/* Do some CreateDirectoryA tests */
|
||||
/* It would be nice to do test the SECURITY_ATTRIBUTES, but I don't
|
||||
really understand how they work.
|
||||
More formal tests should be done along with CreateFile tests
|
||||
*/
|
||||
ok(CreateDirectoryA(newdir,NULL)==0,
|
||||
"CreateDirectoryA succeeded even though a file of the same name exists\n");
|
||||
ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
|
||||
ok(CreateDirectoryA(newdir,NULL),"CreateDirectoryA failed\n");
|
||||
/* Create some files to test other functions. Note, we will test CreateFileA
|
||||
at some later point
|
||||
*/
|
||||
sprintf(tmpstr,"%s\\%s",newdir,SHORTDIR);
|
||||
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
|
||||
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,SHORTFILE);
|
||||
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
||||
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
||||
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,LONGFILE);
|
||||
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
||||
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
||||
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",newdir,LONGDIR,SHORTFILE);
|
||||
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
||||
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
||||
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",newdir,LONGDIR,LONGFILE);
|
||||
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
||||
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
||||
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
||||
}
|
||||
|
||||
/* Test GetCurrentDirectory & SetCurrentDirectory */
|
||||
static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
|
||||
{
|
||||
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH];
|
||||
DWORD len,len1;
|
||||
/* Save the original directory, so that we can return to it at the end
|
||||
of the test
|
||||
*/
|
||||
len=GetCurrentDirectoryA(MAX_PATH,origdir);
|
||||
ok(len!=0 && len < MAX_PATH,"GetCurrentDirectoryA failed\n");
|
||||
ok(lstrcmpiA(origdir+(len-1),"\\")!=0,
|
||||
"GetCurrentDirectoryA should not have a trailing \\\n");
|
||||
/* Make sure that CetCurrentDirectoryA doesn't overwrite the buffer when the
|
||||
buffer size is too small to hold the current directory
|
||||
*/
|
||||
lstrcpyA(tmpstr,"aaaaaaa");
|
||||
len1=GetCurrentDirectoryA(len,tmpstr);
|
||||
ok(len1==len+1, "GetCurrentDirectoryA returned %ld instead of %ld\n",len1,len+1);
|
||||
ok(lstrcmpiA(tmpstr,"aaaaaaa")==0,
|
||||
"GetCurrentDirectoryA should not have modified the buffer\n");
|
||||
/* SetCurrentDirectoryA shouldn't care whether the string has a
|
||||
trailing '\\' or not
|
||||
*/
|
||||
sprintf(tmpstr,"%s\\",newdir);
|
||||
test_setdir(origdir,tmpstr,newdir,1,"check 1");
|
||||
test_setdir(origdir,newdir,NULL,1,"check 2");
|
||||
/* Set the directory to the working area. We just tested that this works,
|
||||
so why check it again.
|
||||
*/
|
||||
SetCurrentDirectoryA(newdir);
|
||||
/* Check that SetCurrentDirectory fails when a non-existent dir is specified */
|
||||
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,NONDIR_SHORT);
|
||||
test_setdir(newdir,tmpstr,NULL,0,"check 3");
|
||||
/* Check that SetCurrentDirectory fails for a non-existent lond directory */
|
||||
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,NONDIR_LONG);
|
||||
test_setdir(newdir,tmpstr,NULL,0,"check 4");
|
||||
/* Check that SetCurrentDirectory passes with a long directory */
|
||||
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
|
||||
test_setdir(newdir,tmpstr,NULL,1,"check 5");
|
||||
/* Check that SetCurrentDirectory passes with a short relative directory */
|
||||
sprintf(tmpstr,"%s",SHORTDIR);
|
||||
sprintf(tmpstr1,"%s\\%s",newdir,SHORTDIR);
|
||||
test_setdir(newdir,tmpstr,tmpstr1,1,"check 6");
|
||||
/* starting with a '.' */
|
||||
sprintf(tmpstr,".\\%s",SHORTDIR);
|
||||
test_setdir(newdir,tmpstr,tmpstr1,1,"check 7");
|
||||
/* Check that SetCurrentDirectory passes with a short relative directory */
|
||||
sprintf(tmpstr,"%s",LONGDIR);
|
||||
sprintf(tmpstr1,"%s\\%s",newdir,LONGDIR);
|
||||
test_setdir(newdir,tmpstr,tmpstr1,1,"check 8");
|
||||
/* starting with a '.' */
|
||||
sprintf(tmpstr,".\\%s",LONGDIR);
|
||||
test_setdir(newdir,tmpstr,tmpstr1,1,"check 9");
|
||||
}
|
||||
|
||||
/* Cleanup the mess we made while executing these tests */
|
||||
static void test_CleanupPathA(CHAR *origdir, CHAR *curdir)
|
||||
{
|
||||
CHAR tmpstr[MAX_PATH];
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
|
||||
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,LONGFILE);
|
||||
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,SHORTFILE);
|
||||
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,LONGFILE);
|
||||
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s",curdir,SHORTDIR);
|
||||
ok(RemoveDirectoryA(tmpstr),"RemoveDirectoryA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s",curdir,LONGDIR);
|
||||
ok(RemoveDirectoryA(tmpstr),"RemoveDirectoryA failed\n");
|
||||
ok(SetCurrentDirectoryA(origdir),"SetCurrentDirectoryA failed\n");
|
||||
ok(RemoveDirectoryA(curdir),"RemoveDirectoryA failed\n");
|
||||
}
|
||||
|
||||
/* This routine will test Get(Full|Short|Long)PathNameA */
|
||||
static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
|
||||
{
|
||||
CHAR curdir_short[MAX_PATH],
|
||||
longdir_short[MAX_PATH];
|
||||
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH],tmpstr2[MAX_PATH];
|
||||
LPSTR strptr; /*ptr to the filename portion of the path */
|
||||
DWORD len;
|
||||
INT i;
|
||||
CHAR dir[MAX_PATH],eight[MAX_PATH],three[MAX_PATH];
|
||||
SLpassfail passfail;
|
||||
|
||||
/* Get the short form of the current directory */
|
||||
ok((len=GetShortPathNameA(curdir,curdir_short,MAX_PATH)),
|
||||
"GetShortPathNameA failed\n");
|
||||
ok(!HAS_TRAIL_SLASH_A(curdir_short),
|
||||
"GetShortPathNameA should not have a trailing \\\n");
|
||||
/* Get the short form of the absolute-path to LONGDIR */
|
||||
sprintf(tmpstr,"%s\\%s",curdir_short,LONGDIR);
|
||||
ok((len=GetShortPathNameA(tmpstr,longdir_short,MAX_PATH)),
|
||||
"GetShortPathNameA failed\n");
|
||||
ok(lstrcmpiA(longdir_short+(len-1),"\\")!=0,
|
||||
"GetShortPathNameA should not have a trailing \\\n");
|
||||
|
||||
if (pGetLongPathNameA) {
|
||||
DWORD rc1,rc2;
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,LONGFILE);
|
||||
rc1=(*pGetLongPathNameA)(tmpstr,NULL,0);
|
||||
rc2=(*pGetLongPathNameA)(curdir,NULL,0);
|
||||
ok((rc1-strlen(tmpstr))==(rc2-strlen(curdir)),
|
||||
"GetLongPathNameA: wrong return code, %ld instead of %d\n",
|
||||
rc1, strlen(tmpstr)+1);
|
||||
|
||||
sprintf(dir,"%c:",curDrive);
|
||||
rc1=(*pGetLongPathNameA)(dir,tmpstr,sizeof(tmpstr));
|
||||
ok(strcmp(dir,tmpstr)==0,
|
||||
"GetLongPathNameA: returned '%s' instead of '%s' (rc=%ld)\n",
|
||||
tmpstr,dir,rc1);
|
||||
}
|
||||
|
||||
/* Check the cases where both file and directory exist first */
|
||||
/* Start with a 8.3 directory, 8.3 filename */
|
||||
test_ValidPathA(curdir,SHORTDIR,SHORTFILE,tmpstr,NULL,"test1");
|
||||
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,SHORTDIR,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetShortPathNameA returned '%s' instead of '%s'\n",tmpstr,tmpstr1);
|
||||
/* Now try a 8.3 directory, long file name */
|
||||
test_ValidPathA(curdir,SHORTDIR,LONGFILE,tmpstr,NULL,"test2");
|
||||
sprintf(tmpstr1,"%s\\%s",curdir_short,SHORTDIR);
|
||||
test_LongtoShortA(tmpstr,tmpstr1,"PAT","test2");
|
||||
/* Next is a long directory, 8.3 file */
|
||||
test_ValidPathA(curdir,LONGDIR,SHORTFILE,tmpstr,NULL,"test3");
|
||||
sprintf(tmpstr1,"%s\\%s",longdir_short,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetShortPathNameA returned '%s' instead of '%s'\n",tmpstr,tmpstr1);
|
||||
/*Lastly a long directory, long file */
|
||||
test_ValidPathA(curdir,LONGDIR,LONGFILE,tmpstr,NULL,"test4");
|
||||
test_LongtoShortA(tmpstr,longdir_short,"PAT","test4");
|
||||
|
||||
/* Now check all of the invalid file w/ valid directory combinations */
|
||||
/* Start with a 8.3 directory, 8.3 filename */
|
||||
test_ValidPathA(curdir,SHORTDIR,NONFILE_SHORT,tmpstr,&passfail,"test5");
|
||||
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,SHORTDIR,NONFILE_SHORT);
|
||||
ok((passfail.shortlen==0 &&
|
||||
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
||||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
||||
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
|
||||
passfail.shortlen,passfail.shorterror,tmpstr);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
||||
}
|
||||
/* Now try a 8.3 directory, long file name */
|
||||
test_ValidPathA(curdir,SHORTDIR,NONFILE_LONG,tmpstr,&passfail,"test6");
|
||||
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
||||
!passfail.shorterror,
|
||||
"GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
||||
}
|
||||
/* Next is a long directory, 8.3 file */
|
||||
test_ValidPathA(curdir,LONGDIR,NONFILE_SHORT,tmpstr,&passfail,"test7");
|
||||
sprintf(tmpstr2,"%s\\%s",curdir_short,LONGDIR);
|
||||
GetShortPathNameA(tmpstr2,tmpstr1,MAX_PATH);
|
||||
strcat(tmpstr1,"\\" NONFILE_SHORT);
|
||||
ok((passfail.shortlen==0 &&
|
||||
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
||||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
||||
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
|
||||
passfail.shortlen,passfail.shorterror,tmpstr);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
||||
}
|
||||
/*Lastly a long directory, long file */
|
||||
test_ValidPathA(curdir,LONGDIR,NONFILE_LONG,tmpstr,&passfail,"test8");
|
||||
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
||||
!passfail.shorterror,
|
||||
"GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
||||
}
|
||||
/* Now try again with directories that don't exist */
|
||||
/* 8.3 directory, 8.3 filename */
|
||||
test_ValidPathA(curdir,NONDIR_SHORT,SHORTFILE,tmpstr,&passfail,"test9");
|
||||
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,NONDIR_SHORT,SHORTFILE);
|
||||
ok((passfail.shortlen==0 &&
|
||||
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
||||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
||||
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
|
||||
passfail.shortlen,passfail.shorterror,tmpstr);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.longerror);
|
||||
}
|
||||
/* Now try a 8.3 directory, long file name */
|
||||
test_ValidPathA(curdir,NONDIR_SHORT,LONGFILE,tmpstr,&passfail,"test10");
|
||||
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
||||
!passfail.shorterror,
|
||||
"GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.shorterror);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.longerror);
|
||||
}
|
||||
/* Next is a long directory, 8.3 file */
|
||||
test_ValidPathA(curdir,NONDIR_LONG,SHORTFILE,tmpstr,&passfail,"test11");
|
||||
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
||||
!passfail.shorterror,
|
||||
"GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.shorterror);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.longerror);
|
||||
}
|
||||
/*Lastly a long directory, long file */
|
||||
test_ValidPathA(curdir,NONDIR_LONG,LONGFILE,tmpstr,&passfail,"test12");
|
||||
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
||||
!passfail.shorterror,
|
||||
"GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.shorterror);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
|
||||
passfail.longerror);
|
||||
}
|
||||
/* Next try directories ending with '\\' */
|
||||
/* Existing Directories */
|
||||
sprintf(tmpstr,"%s\\",SHORTDIR);
|
||||
test_ValidPathA(curdir,"",tmpstr,tmpstr1,NULL,"test13");
|
||||
sprintf(tmpstr,"%s\\",LONGDIR);
|
||||
test_ValidPathA(curdir,"",tmpstr,tmpstr1,NULL,"test14");
|
||||
/* Non-existent directories */
|
||||
sprintf(tmpstr,"%s\\",NONDIR_SHORT);
|
||||
test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test15");
|
||||
sprintf(tmpstr2,"%s\\%s",curdir,tmpstr);
|
||||
ok((passfail.shortlen==0 &&
|
||||
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
||||
(passfail.shortlen==strlen(tmpstr2) && lstrcmpiA(tmpstr1,tmpstr2)==0),
|
||||
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
|
||||
passfail.shortlen,passfail.shorterror,tmpstr);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetLongPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
|
||||
passfail.longerror);
|
||||
}
|
||||
sprintf(tmpstr,"%s\\",NONDIR_LONG);
|
||||
test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test16");
|
||||
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
||||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
||||
!passfail.shorterror,
|
||||
"GetShortPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
|
||||
passfail.shorterror);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
||||
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
||||
"GetLongPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
|
||||
passfail.longerror);
|
||||
}
|
||||
/* Test GetFullPathNameA with drive letters */
|
||||
if( curDrive != NOT_A_VALID_DRIVE) {
|
||||
sprintf(tmpstr,"%c:",curdir[0]);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr2,&strptr),
|
||||
"GetFullPathNameA(%c:) failed\n", curdir[0]);
|
||||
GetCurrentDirectoryA(MAX_PATH,tmpstr);
|
||||
sprintf(tmpstr1,"%s\\",tmpstr);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr2)==0 || lstrcmpiA(tmpstr1,tmpstr2)==0,
|
||||
"GetFullPathNameA(%c:) returned '%s' instead of '%s' or '%s'\n",
|
||||
curdir[0],tmpstr2,tmpstr,tmpstr1);
|
||||
|
||||
sprintf(tmpstr,"%c:\\%s\\%s",curDrive,SHORTDIR,SHORTFILE);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
||||
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
||||
}
|
||||
/* Without a leading slash, insert the current directory if on the current drive */
|
||||
sprintf(tmpstr,"%c:%s\\%s",curdir[0],SHORTDIR,SHORTFILE);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
||||
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
||||
/* Otherwise insert the missing leading slash */
|
||||
if( otherDrive != NOT_A_VALID_DRIVE) {
|
||||
sprintf(tmpstr,"%c:%s\\%s",otherDrive,SHORTDIR,SHORTFILE);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed for %s\n", tmpstr);
|
||||
sprintf(tmpstr,"%c:\\%s\\%s",otherDrive,SHORTDIR,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
||||
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
||||
}
|
||||
/* Xilinx tools like to mix Unix and DOS formats, which Windows handles fine.
|
||||
So test for them. */
|
||||
if( curDrive != NOT_A_VALID_DRIVE) {
|
||||
sprintf(tmpstr,"%c:/%s\\%s",curDrive,SHORTDIR,SHORTFILE);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
||||
sprintf(tmpstr,"%c:\\%s\\%s",curDrive,SHORTDIR,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
||||
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
||||
}
|
||||
/**/
|
||||
sprintf(tmpstr,"%c:%s/%s",curdir[0],SHORTDIR,SHORTFILE);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
||||
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
||||
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
||||
/* Windows will insert a drive letter in front of an absolute UNIX path, but
|
||||
Wine probably shouldn't. */
|
||||
sprintf(tmpstr,"/%s/%s",SHORTDIR,SHORTFILE);
|
||||
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
||||
todo_wine {
|
||||
if( curDrive != NOT_A_VALID_DRIVE) {
|
||||
sprintf(tmpstr,"C:\\%s\\%s",SHORTDIR,SHORTFILE);
|
||||
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
||||
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
}
|
||||
}
|
||||
/* This passes in Wine because it still contains the pointer from the previous test */
|
||||
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
||||
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
||||
|
||||
/* Now try some relative paths */
|
||||
ok(GetShortPathNameA(LONGDIR,tmpstr,MAX_PATH),"GetShortPathNameA failed\n");
|
||||
test_SplitShortPathA(tmpstr,dir,eight,three);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(pGetLongPathNameA(tmpstr,tmpstr1,MAX_PATH),"GetLongPathNameA failed\n");
|
||||
ok(lstrcmpiA(tmpstr1,LONGDIR)==0,
|
||||
"GetLongPathNameA returned '%s' instead of '%s'\n",tmpstr1,LONGDIR);
|
||||
}
|
||||
sprintf(tmpstr,".\\%s",LONGDIR);
|
||||
ok(GetShortPathNameA(tmpstr,tmpstr1,MAX_PATH),"GetShortPathNameA failed\n");
|
||||
test_SplitShortPathA(tmpstr1,dir,eight,three);
|
||||
ok(lstrcmpiA(dir,".")==0 || dir[0]=='\0',
|
||||
"GetShortPathNameA did not keep relative directory [%s]\n",tmpstr1);
|
||||
if(pGetLongPathNameA) {
|
||||
ok(pGetLongPathNameA(tmpstr1,tmpstr1,MAX_PATH),"GetLongPathNameA failed %s\n",
|
||||
tmpstr);
|
||||
ok(lstrcmpiA(tmpstr1,tmpstr)==0,
|
||||
"GetLongPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
||||
}
|
||||
/* Check out Get*PathNameA on some funny characters */
|
||||
for(i=0;i<lstrlenA(funny_chars);i++) {
|
||||
INT valid;
|
||||
valid=(is_char_ok[i]=='0') ? 0 : 1;
|
||||
sprintf(tmpstr1,"check%d-1",i);
|
||||
sprintf(tmpstr,"file%c000.ext",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
sprintf(tmpstr1,"check%d-2",i);
|
||||
sprintf(tmpstr,"file000.e%ct",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
sprintf(tmpstr1,"check%d-3",i);
|
||||
sprintf(tmpstr,"%cfile000.ext",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
sprintf(tmpstr1,"check%d-4",i);
|
||||
sprintf(tmpstr,"file000%c.ext",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
sprintf(tmpstr1,"check%d-5",i);
|
||||
sprintf(tmpstr,"Long %c File",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
sprintf(tmpstr1,"check%d-6",i);
|
||||
sprintf(tmpstr,"%c Long File",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
sprintf(tmpstr1,"check%d-7",i);
|
||||
sprintf(tmpstr,"Long File %c",funny_chars[i]);
|
||||
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_GetTempPathA(char* tmp_dir)
|
||||
{
|
||||
DWORD len, len_with_null;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
len_with_null = strlen(tmp_dir) + 1;
|
||||
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetTempPathA(MAX_PATH, buf);
|
||||
ok(len <= MAX_PATH, "should fit into MAX_PATH\n");
|
||||
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
|
||||
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
||||
|
||||
/* Some versions of Windows touch the buffer, some don't so we don't
|
||||
* test that. Also, NT sometimes exagerates the required buffer size
|
||||
* so we cannot test for an exact match. Finally, the
|
||||
* 'len_with_null - 1' case is so buggy on Windows it's not testable.
|
||||
* For instance in some cases Win98 returns len_with_null - 1 instead
|
||||
* of len_with_null.
|
||||
*/
|
||||
len = GetTempPathA(1, buf);
|
||||
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
|
||||
|
||||
len = GetTempPathA(0, NULL);
|
||||
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
|
||||
|
||||
/* The call above gave us the buffer size that Windows thinks is needed
|
||||
* so the next call should work
|
||||
*/
|
||||
lstrcpyA(buf, "foo");
|
||||
len = GetTempPathA(len, buf);
|
||||
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
|
||||
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
||||
}
|
||||
|
||||
static void test_GetTempPathW(char* tmp_dir)
|
||||
{
|
||||
DWORD len, len_with_null;
|
||||
WCHAR buf[MAX_PATH];
|
||||
WCHAR tmp_dirW[MAX_PATH];
|
||||
static const WCHAR fooW[] = {'f','o','o',0};
|
||||
|
||||
MultiByteToWideChar(CP_ACP,0,tmp_dir,-1,tmp_dirW,sizeof(tmp_dirW)/sizeof(*tmp_dirW));
|
||||
len_with_null = lstrlenW(tmp_dirW) + 1;
|
||||
|
||||
/* This one is different from ANSI version: ANSI version doesn't
|
||||
* touch the buffer, unicode version usually truncates the buffer
|
||||
* to zero size. NT still exagerates the required buffer size
|
||||
* sometimes so we cannot test for an exact match. Finally, the
|
||||
* 'len_with_null - 1' case is so buggy on Windows it's not testable.
|
||||
* For instance on NT4 it will sometimes return a path without the
|
||||
* trailing '\\' and sometimes return an error.
|
||||
*/
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetTempPathW(MAX_PATH, buf);
|
||||
if (len==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
|
||||
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetTempPathW(1, buf);
|
||||
ok(buf[0] == 0, "unicode version should truncate the buffer to zero size\n");
|
||||
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
|
||||
|
||||
len = GetTempPathW(0, NULL);
|
||||
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
|
||||
|
||||
lstrcpyW(buf, fooW);
|
||||
len = GetTempPathW(len, buf);
|
||||
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
|
||||
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
||||
}
|
||||
|
||||
static void test_GetTempPath(void)
|
||||
{
|
||||
char save_TMP[MAX_PATH];
|
||||
char windir[MAX_PATH];
|
||||
char buf[MAX_PATH];
|
||||
|
||||
GetEnvironmentVariableA("TMP", save_TMP, sizeof(save_TMP));
|
||||
|
||||
/* test default configuration */
|
||||
trace("TMP=%s\n", save_TMP);
|
||||
strcpy(buf,save_TMP);
|
||||
if (buf[strlen(buf)-1]!='\\')
|
||||
strcat(buf,"\\");
|
||||
test_GetTempPathA(buf);
|
||||
test_GetTempPathW(buf);
|
||||
|
||||
/* TMP=C:\WINDOWS */
|
||||
GetWindowsDirectoryA(windir, sizeof(windir));
|
||||
SetEnvironmentVariableA("TMP", windir);
|
||||
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
|
||||
trace("TMP=%s\n", buf);
|
||||
strcat(windir,"\\");
|
||||
test_GetTempPathA(windir);
|
||||
test_GetTempPathW(windir);
|
||||
|
||||
/* TMP=C:\ */
|
||||
GetWindowsDirectoryA(windir, sizeof(windir));
|
||||
windir[3] = 0;
|
||||
SetEnvironmentVariableA("TMP", windir);
|
||||
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
|
||||
trace("TMP=%s\n", buf);
|
||||
test_GetTempPathA(windir);
|
||||
test_GetTempPathW(windir);
|
||||
|
||||
/* TMP=C: i.e. use current working directory of the specified drive */
|
||||
GetWindowsDirectoryA(windir, sizeof(windir));
|
||||
SetCurrentDirectoryA(windir);
|
||||
windir[2] = 0;
|
||||
SetEnvironmentVariableA("TMP", windir);
|
||||
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
|
||||
trace("TMP=%s\n", buf);
|
||||
GetWindowsDirectoryA(windir, sizeof(windir));
|
||||
strcat(windir,"\\");
|
||||
test_GetTempPathA(windir);
|
||||
test_GetTempPathW(windir);
|
||||
|
||||
SetEnvironmentVariableA("TMP", save_TMP);
|
||||
}
|
||||
|
||||
START_TEST(path)
|
||||
{
|
||||
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
|
||||
pGetLongPathNameA = (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
|
||||
"GetLongPathNameA" );
|
||||
test_InitPathA(curdir, &curDrive, &otherDrive);
|
||||
test_CurrentDirectoryA(origdir,curdir);
|
||||
test_PathNameA(curdir, curDrive, otherDrive);
|
||||
test_CleanupPathA(origdir,curdir);
|
||||
test_GetTempPath();
|
||||
}
|
|
@ -1,763 +0,0 @@
|
|||
/*
|
||||
* Unit tests for named pipe functions in Wine
|
||||
*
|
||||
* Copyright (c) 2002 Dan Kegel
|
||||
*
|
||||
* 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 <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winsock.h>
|
||||
|
||||
#ifndef STANDALONE
|
||||
#include "wine/test.h"
|
||||
#else
|
||||
#include <assert.h>
|
||||
#define START_TEST(name) main(int argc, char **argv)
|
||||
#define ok(condition, msg) \
|
||||
do { \
|
||||
if(!(condition)) \
|
||||
{ \
|
||||
fprintf(stderr,"failed at %d\n",__LINE__); \
|
||||
exit(0); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define todo_wine
|
||||
#endif
|
||||
|
||||
#include <wtypes.h>
|
||||
#include <winerror.h>
|
||||
|
||||
#define PIPENAME "\\\\.\\PiPe\\tests_" __FILE__
|
||||
|
||||
#define NB_SERVER_LOOPS 8
|
||||
|
||||
static HANDLE alarm_event;
|
||||
|
||||
static void test_CreateNamedPipe(pipemode)
|
||||
{
|
||||
HANDLE hnp;
|
||||
HANDLE hFile;
|
||||
static const char obuf[] = "Bit Bucket";
|
||||
static const char obuf2[] = "More bits";
|
||||
char ibuf[32], *pbuf;
|
||||
DWORD written;
|
||||
DWORD readden;
|
||||
DWORD avail;
|
||||
DWORD lpmode;
|
||||
|
||||
if (pipemode == PIPE_TYPE_BYTE)
|
||||
trace("test_CreateNamedPipe starting in byte mode\n");
|
||||
else
|
||||
trace("test_CreateNamedPipe starting in message mode\n");
|
||||
/* Bad parameter checks */
|
||||
hnp = CreateNamedPipe("not a named pipe", PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
|
||||
if (hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
/* Is this the right way to notify user of skipped tests? */
|
||||
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
|
||||
"CreateNamedPipe not supported on this platform, skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_NAME,
|
||||
"CreateNamedPipe should fail if name doesn't start with \\\\.\\pipe\n");
|
||||
|
||||
hnp = CreateNamedPipe(NULL,
|
||||
PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
|
||||
1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
|
||||
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
|
||||
"CreateNamedPipe should fail if name is NULL\n");
|
||||
|
||||
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hFile == INVALID_HANDLE_VALUE
|
||||
&& GetLastError() == ERROR_FILE_NOT_FOUND,
|
||||
"connecting to nonexistent named pipe should fail with ERROR_FILE_NOT_FOUND\n");
|
||||
|
||||
/* Functional checks */
|
||||
|
||||
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed\n");
|
||||
|
||||
/* don't try to do i/o if one side couldn't be opened, as it hangs */
|
||||
if (hFile != INVALID_HANDLE_VALUE) {
|
||||
HANDLE hFile2;
|
||||
|
||||
/* Make sure we can read and write a few bytes in both directions */
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
|
||||
ok(written == sizeof(obuf), "write file len 1\n");
|
||||
ok(PeekNamedPipe(hFile, NULL, 0, NULL, &readden, NULL), "Peek\n");
|
||||
ok(readden == sizeof(obuf), "peek 1 got %ld bytes\n", readden);
|
||||
ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
ok(readden == sizeof(obuf), "read 1 got %ld bytes\n", readden);
|
||||
ok(memcmp(obuf, ibuf, written) == 0, "content 1 check\n");
|
||||
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
|
||||
ok(written == sizeof(obuf2), "write file len 2\n");
|
||||
ok(PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL), "Peek\n");
|
||||
ok(readden == sizeof(obuf2), "peek 2 got %ld bytes\n", readden);
|
||||
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
ok(readden == sizeof(obuf2), "read 2 got %ld bytes\n", readden);
|
||||
ok(memcmp(obuf2, ibuf, written) == 0, "content 2 check\n");
|
||||
|
||||
/* Test reading of multiple writes */
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile3a\n");
|
||||
ok(written == sizeof(obuf), "write file len 3a\n");
|
||||
ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile3b\n");
|
||||
ok(written == sizeof(obuf2), "write file len 3b\n");
|
||||
ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek3\n");
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
todo_wine {
|
||||
/* should return all 23 bytes */
|
||||
ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes\n", readden);
|
||||
}
|
||||
}
|
||||
else
|
||||
ok(readden == sizeof(obuf), "peek3 got %ld bytes\n", readden);
|
||||
todo_wine {
|
||||
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes available\n", avail);
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 3a check\n");
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
todo_wine {
|
||||
pbuf += sizeof(obuf);
|
||||
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "pipe content 3b check\n");
|
||||
}
|
||||
}
|
||||
ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
ok(readden == sizeof(obuf) + sizeof(obuf2), "read 3 got %ld bytes\n", readden);
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 3a check\n");
|
||||
pbuf += sizeof(obuf);
|
||||
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 3b check\n");
|
||||
|
||||
/* Multiple writes in the reverse direction */
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile4a\n");
|
||||
ok(written == sizeof(obuf), "write file len 4a\n");
|
||||
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile4b\n");
|
||||
ok(written == sizeof(obuf2), "write file len 4b\n");
|
||||
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek4\n");
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
todo_wine {
|
||||
/* should return all 23 bytes */
|
||||
ok(readden == sizeof(obuf) + sizeof(obuf2), "peek4 got %ld bytes\n", readden);
|
||||
}
|
||||
}
|
||||
else
|
||||
ok(readden == sizeof(obuf), "peek4 got %ld bytes\n", readden);
|
||||
todo_wine {
|
||||
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek4 got %ld bytes available\n", avail);
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 4a check\n");
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
todo_wine {
|
||||
pbuf += sizeof(obuf);
|
||||
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "pipe content 4b check\n");
|
||||
}
|
||||
}
|
||||
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
ok(readden == sizeof(obuf) + sizeof(obuf2), "read 4 got %ld bytes\n", readden);
|
||||
}
|
||||
else {
|
||||
todo_wine {
|
||||
ok(readden == sizeof(obuf), "read 4 got %ld bytes\n", readden);
|
||||
}
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 4a check\n");
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
pbuf += sizeof(obuf);
|
||||
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 4b check\n");
|
||||
}
|
||||
|
||||
/* Test reading of multiple writes after a mode change
|
||||
(CreateFile always creates a byte mode pipe) */
|
||||
lpmode = PIPE_READMODE_MESSAGE;
|
||||
if (pipemode == PIPE_TYPE_BYTE) {
|
||||
/* trying to change the client end of a byte pipe to message mode should fail */
|
||||
ok(!SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
|
||||
}
|
||||
else {
|
||||
todo_wine {
|
||||
ok(SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
|
||||
}
|
||||
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile5a\n");
|
||||
ok(written == sizeof(obuf), "write file len 3a\n");
|
||||
ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile5b\n");
|
||||
ok(written == sizeof(obuf2), "write file len 3b\n");
|
||||
ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek5\n");
|
||||
ok(readden == sizeof(obuf), "peek5 got %ld bytes\n", readden);
|
||||
todo_wine {
|
||||
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek5 got %ld bytes available\n", avail);
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
|
||||
ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
todo_wine {
|
||||
ok(readden == sizeof(obuf), "read 5 got %ld bytes\n", readden);
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
|
||||
|
||||
/* Multiple writes in the reverse direction */
|
||||
/* the write of obuf2 from write4 should still be in the buffer */
|
||||
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6a\n");
|
||||
todo_wine {
|
||||
ok(readden == sizeof(obuf2), "peek6a got %ld bytes\n", readden);
|
||||
ok(avail == sizeof(obuf2), "peek6a got %ld bytes available\n", avail);
|
||||
}
|
||||
if (avail > 0) {
|
||||
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
ok(readden == sizeof(obuf2), "read 6a got %ld bytes\n", readden);
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 6a check\n");
|
||||
}
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile6a\n");
|
||||
ok(written == sizeof(obuf), "write file len 6a\n");
|
||||
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile6b\n");
|
||||
ok(written == sizeof(obuf2), "write file len 6b\n");
|
||||
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6\n");
|
||||
ok(readden == sizeof(obuf), "peek6 got %ld bytes\n", readden);
|
||||
todo_wine {
|
||||
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek6b got %ld bytes available\n", avail);
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
|
||||
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
|
||||
todo_wine {
|
||||
ok(readden == sizeof(obuf), "read 6b got %ld bytes\n", readden);
|
||||
}
|
||||
pbuf = ibuf;
|
||||
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
|
||||
}
|
||||
|
||||
/* Picky conformance tests */
|
||||
|
||||
/* Verify that you can't connect to pipe again
|
||||
* until server calls DisconnectNamedPipe+ConnectNamedPipe
|
||||
* or creates a new pipe
|
||||
* case 1: other client not yet closed
|
||||
*/
|
||||
hFile2 = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hFile2 == INVALID_HANDLE_VALUE,
|
||||
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail\n");
|
||||
ok(GetLastError() == ERROR_PIPE_BUSY,
|
||||
"connecting to named pipe before other client closes should fail with ERROR_PIPE_BUSY\n");
|
||||
|
||||
ok(CloseHandle(hFile), "CloseHandle\n");
|
||||
|
||||
/* case 2: other client already closed */
|
||||
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hFile == INVALID_HANDLE_VALUE,
|
||||
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail\n");
|
||||
ok(GetLastError() == ERROR_PIPE_BUSY,
|
||||
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail with ERROR_PIPE_BUSY\n");
|
||||
|
||||
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
|
||||
|
||||
/* case 3: server has called DisconnectNamedPipe but not ConnectNamed Pipe */
|
||||
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hFile == INVALID_HANDLE_VALUE,
|
||||
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail\n");
|
||||
ok(GetLastError() == ERROR_PIPE_BUSY,
|
||||
"connecting to named pipe after other client closes but before ConnectNamedPipe should fail with ERROR_PIPE_BUSY\n");
|
||||
|
||||
/* to be complete, we'd call ConnectNamedPipe here and loop,
|
||||
* but by default that's blocking, so we'd either have
|
||||
* to turn on the uncommon nonblocking mode, or
|
||||
* use another thread.
|
||||
*/
|
||||
}
|
||||
|
||||
ok(CloseHandle(hnp), "CloseHandle\n");
|
||||
|
||||
trace("test_CreateNamedPipe returning\n");
|
||||
}
|
||||
|
||||
void test_CreateNamedPipe_instances_must_match(void)
|
||||
{
|
||||
HANDLE hnp, hnp2;
|
||||
|
||||
/* Check no mismatch */
|
||||
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 2,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 2,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp2 != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
ok(CloseHandle(hnp), "CloseHandle\n");
|
||||
ok(CloseHandle(hnp2), "CloseHandle\n");
|
||||
|
||||
/* Check nMaxInstances */
|
||||
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp2 == INVALID_HANDLE_VALUE
|
||||
&& GetLastError() == ERROR_PIPE_BUSY, "nMaxInstances not obeyed\n");
|
||||
|
||||
ok(CloseHandle(hnp), "CloseHandle\n");
|
||||
|
||||
/* Check PIPE_ACCESS_* */
|
||||
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 2,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp2 == INVALID_HANDLE_VALUE
|
||||
&& GetLastError() == ERROR_ACCESS_DENIED, "PIPE_ACCESS_* mismatch allowed\n");
|
||||
|
||||
ok(CloseHandle(hnp), "CloseHandle\n");
|
||||
|
||||
/* etc, etc */
|
||||
}
|
||||
|
||||
/** implementation of alarm() */
|
||||
static DWORD CALLBACK alarmThreadMain(LPVOID arg)
|
||||
{
|
||||
DWORD timeout = (DWORD) arg;
|
||||
trace("alarmThreadMain\n");
|
||||
if (WaitForSingleObject( alarm_event, timeout ) == WAIT_TIMEOUT)
|
||||
{
|
||||
ok(FALSE, "alarm\n");
|
||||
ExitProcess(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
HANDLE hnp = INVALID_HANDLE_VALUE;
|
||||
|
||||
/** Trivial byte echo server - disconnects after each session */
|
||||
static DWORD CALLBACK serverThreadMain1(LPVOID arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
trace("serverThreadMain1 start\n");
|
||||
/* Set up a simple echo server */
|
||||
hnp = CreateNamedPipe(PIPENAME "serverThreadMain1", PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
for (i = 0; i < NB_SERVER_LOOPS; i++) {
|
||||
char buf[512];
|
||||
DWORD written;
|
||||
DWORD readden;
|
||||
DWORD success;
|
||||
|
||||
/* Wait for client to connect */
|
||||
trace("Server calling ConnectNamedPipe...\n");
|
||||
ok(ConnectNamedPipe(hnp, NULL)
|
||||
|| GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n");
|
||||
trace("ConnectNamedPipe returned.\n");
|
||||
|
||||
/* Echo bytes once */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
trace("Server reading...\n");
|
||||
success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
|
||||
trace("Server done reading.\n");
|
||||
ok(success, "ReadFile\n");
|
||||
ok(readden, "short read\n");
|
||||
|
||||
trace("Server writing...\n");
|
||||
ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n");
|
||||
trace("Server done writing.\n");
|
||||
ok(written == readden, "write file len\n");
|
||||
|
||||
/* finish this connection, wait for next one */
|
||||
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
|
||||
trace("Server done flushing.\n");
|
||||
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
|
||||
trace("Server done disconnecting.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Trivial byte echo server - closes after each connection */
|
||||
static DWORD CALLBACK serverThreadMain2(LPVOID arg)
|
||||
{
|
||||
int i;
|
||||
HANDLE hnpNext = 0;
|
||||
|
||||
trace("serverThreadMain2\n");
|
||||
/* Set up a simple echo server */
|
||||
hnp = CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 2,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
for (i = 0; i < NB_SERVER_LOOPS; i++) {
|
||||
char buf[512];
|
||||
DWORD written;
|
||||
DWORD readden;
|
||||
DWORD success;
|
||||
|
||||
/* Wait for client to connect */
|
||||
trace("Server calling ConnectNamedPipe...\n");
|
||||
ok(ConnectNamedPipe(hnp, NULL)
|
||||
|| GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n");
|
||||
trace("ConnectNamedPipe returned.\n");
|
||||
|
||||
/* Echo bytes once */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
trace("Server reading...\n");
|
||||
success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
|
||||
trace("Server done reading.\n");
|
||||
ok(success, "ReadFile\n");
|
||||
|
||||
trace("Server writing...\n");
|
||||
ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n");
|
||||
trace("Server done writing.\n");
|
||||
ok(written == readden, "write file len\n");
|
||||
|
||||
/* finish this connection, wait for next one */
|
||||
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
|
||||
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
|
||||
|
||||
/* Set up next echo server */
|
||||
hnpNext =
|
||||
CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 2,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
|
||||
ok(hnpNext != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
ok(CloseHandle(hnp), "CloseHandle\n");
|
||||
hnp = hnpNext;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Trivial byte echo server - uses overlapped named pipe calls */
|
||||
static DWORD CALLBACK serverThreadMain3(LPVOID arg)
|
||||
{
|
||||
int i;
|
||||
HANDLE hEvent;
|
||||
|
||||
trace("serverThreadMain3\n");
|
||||
/* Set up a simple echo server */
|
||||
hnp = CreateNamedPipe(PIPENAME "serverThreadMain3", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
hEvent = CreateEvent(NULL, /* security attribute */
|
||||
TRUE, /* manual reset event */
|
||||
FALSE, /* initial state */
|
||||
NULL); /* name */
|
||||
ok(hEvent != NULL, "CreateEvent\n");
|
||||
|
||||
for (i = 0; i < NB_SERVER_LOOPS; i++) {
|
||||
char buf[512];
|
||||
DWORD written;
|
||||
DWORD readden;
|
||||
DWORD dummy;
|
||||
DWORD success;
|
||||
OVERLAPPED oOverlap;
|
||||
int letWFSOEwait = (i & 2);
|
||||
int letGORwait = (i & 1);
|
||||
DWORD err;
|
||||
|
||||
memset(&oOverlap, 0, sizeof(oOverlap));
|
||||
oOverlap.hEvent = hEvent;
|
||||
|
||||
/* Wait for client to connect */
|
||||
trace("Server calling overlapped ConnectNamedPipe...\n");
|
||||
success = ConnectNamedPipe(hnp, &oOverlap);
|
||||
err = GetLastError();
|
||||
ok(success || err == ERROR_IO_PENDING
|
||||
|| err == ERROR_PIPE_CONNECTED, "overlapped ConnectNamedPipe\n");
|
||||
trace("overlapped ConnectNamedPipe returned.\n");
|
||||
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
|
||||
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ConnectNamedPipe\n");
|
||||
success = GetOverlappedResult(hnp, &oOverlap, &dummy, letGORwait);
|
||||
if (!letGORwait && !letWFSOEwait && !success) {
|
||||
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
|
||||
success = GetOverlappedResult(hnp, &oOverlap, &dummy, TRUE);
|
||||
}
|
||||
ok(success, "GetOverlappedResult ConnectNamedPipe\n");
|
||||
trace("overlapped ConnectNamedPipe operation complete.\n");
|
||||
|
||||
/* Echo bytes once */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
trace("Server reading...\n");
|
||||
success = ReadFile(hnp, buf, sizeof(buf), NULL, &oOverlap);
|
||||
trace("Server ReadFile returned...\n");
|
||||
err = GetLastError();
|
||||
ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile\n");
|
||||
trace("overlapped ReadFile returned.\n");
|
||||
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
|
||||
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ReadFile\n");
|
||||
success = GetOverlappedResult(hnp, &oOverlap, &readden, letGORwait);
|
||||
if (!letGORwait && !letWFSOEwait && !success) {
|
||||
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
|
||||
success = GetOverlappedResult(hnp, &oOverlap, &readden, TRUE);
|
||||
}
|
||||
trace("Server done reading.\n");
|
||||
ok(success, "overlapped ReadFile\n");
|
||||
|
||||
trace("Server writing...\n");
|
||||
success = WriteFile(hnp, buf, readden, NULL, &oOverlap);
|
||||
trace("Server WriteFile returned...\n");
|
||||
err = GetLastError();
|
||||
ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile\n");
|
||||
trace("overlapped WriteFile returned.\n");
|
||||
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
|
||||
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait WriteFile\n");
|
||||
success = GetOverlappedResult(hnp, &oOverlap, &written, letGORwait);
|
||||
if (!letGORwait && !letWFSOEwait && !success) {
|
||||
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
|
||||
success = GetOverlappedResult(hnp, &oOverlap, &written, TRUE);
|
||||
}
|
||||
trace("Server done writing.\n");
|
||||
ok(success, "overlapped WriteFile\n");
|
||||
ok(written == readden, "write file len\n");
|
||||
|
||||
/* finish this connection, wait for next one */
|
||||
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
|
||||
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void exercizeServer(const char *pipename, HANDLE serverThread)
|
||||
{
|
||||
int i;
|
||||
|
||||
trace("exercizeServer starting\n");
|
||||
for (i = 0; i < NB_SERVER_LOOPS; i++) {
|
||||
HANDLE hFile=INVALID_HANDLE_VALUE;
|
||||
static const char obuf[] = "Bit Bucket";
|
||||
char ibuf[32];
|
||||
DWORD written;
|
||||
DWORD readden;
|
||||
int loop;
|
||||
|
||||
for (loop = 0; loop < 3; loop++) {
|
||||
DWORD err;
|
||||
trace("Client connecting...\n");
|
||||
/* Connect to the server */
|
||||
hFile = CreateFileA(pipename, GENERIC_READ | GENERIC_WRITE, 0,
|
||||
NULL, OPEN_EXISTING, 0, 0);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
break;
|
||||
err = GetLastError();
|
||||
if (loop == 0)
|
||||
ok(err == ERROR_PIPE_BUSY || err == ERROR_FILE_NOT_FOUND, "connecting to pipe\n");
|
||||
else
|
||||
ok(err == ERROR_PIPE_BUSY, "connecting to pipe\n");
|
||||
trace("connect failed, retrying\n");
|
||||
Sleep(200);
|
||||
}
|
||||
ok(hFile != INVALID_HANDLE_VALUE, "client opening named pipe\n");
|
||||
|
||||
/* Make sure it can echo */
|
||||
memset(ibuf, 0, sizeof(ibuf));
|
||||
trace("Client writing...\n");
|
||||
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile to client end of pipe\n");
|
||||
ok(written == sizeof(obuf), "write file len\n");
|
||||
trace("Client reading...\n");
|
||||
ok(ReadFile(hFile, ibuf, sizeof(obuf), &readden, NULL), "ReadFile from client end of pipe\n");
|
||||
ok(readden == sizeof(obuf), "read file len\n");
|
||||
ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
|
||||
|
||||
trace("Client closing...\n");
|
||||
ok(CloseHandle(hFile), "CloseHandle\n");
|
||||
}
|
||||
|
||||
ok(WaitForSingleObject(serverThread,INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject\n");
|
||||
CloseHandle(hnp);
|
||||
trace("exercizeServer returning\n");
|
||||
}
|
||||
|
||||
static void test_NamedPipe_2(void)
|
||||
{
|
||||
HANDLE serverThread;
|
||||
DWORD serverThreadId;
|
||||
HANDLE alarmThread;
|
||||
DWORD alarmThreadId;
|
||||
|
||||
trace("test_NamedPipe_2 starting\n");
|
||||
/* Set up a ten second timeout */
|
||||
alarm_event = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
alarmThread = CreateThread(NULL, 0, alarmThreadMain, (void *) 10000, 0, &alarmThreadId);
|
||||
|
||||
/* The servers we're about to exercize do try to clean up carefully,
|
||||
* but to reduce the change of a test failure due to a pipe handle
|
||||
* leak in the test code, we'll use a different pipe name for each server.
|
||||
*/
|
||||
|
||||
/* Try server #1 */
|
||||
serverThread = CreateThread(NULL, 0, serverThreadMain1, (void *)8, 0, &serverThreadId);
|
||||
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
|
||||
exercizeServer(PIPENAME "serverThreadMain1", serverThread);
|
||||
|
||||
/* Try server #2 */
|
||||
serverThread = CreateThread(NULL, 0, serverThreadMain2, 0, 0, &serverThreadId);
|
||||
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
|
||||
exercizeServer(PIPENAME "serverThreadMain2", serverThread);
|
||||
|
||||
if( 0 ) /* overlapped pipe server doesn't work yet - it randomly fails */
|
||||
{
|
||||
/* Try server #3 */
|
||||
serverThread = CreateThread(NULL, 0, serverThreadMain3, 0, 0, &serverThreadId);
|
||||
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
|
||||
exercizeServer(PIPENAME "serverThreadMain3", serverThread);
|
||||
}
|
||||
|
||||
ok(SetEvent( alarm_event ), "SetEvent\n");
|
||||
CloseHandle( alarm_event );
|
||||
trace("test_NamedPipe_2 returning\n");
|
||||
}
|
||||
|
||||
static void test_DisconnectNamedPipe(void)
|
||||
{
|
||||
HANDLE hnp;
|
||||
HANDLE hFile;
|
||||
static const char obuf[] = "Bit Bucket";
|
||||
char ibuf[32];
|
||||
DWORD written;
|
||||
DWORD readden;
|
||||
|
||||
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
/* nMaxInstances */ 1,
|
||||
/* nOutBufSize */ 1024,
|
||||
/* nInBufSize */ 1024,
|
||||
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
|
||||
/* lpSecurityAttrib */ NULL);
|
||||
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
|
||||
|
||||
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL) == 0
|
||||
&& GetLastError() == ERROR_PIPE_LISTENING, "WriteFile to not-yet-connected pipe\n");
|
||||
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0
|
||||
&& GetLastError() == ERROR_PIPE_LISTENING, "ReadFile from not-yet-connected pipe\n");
|
||||
|
||||
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed\n");
|
||||
|
||||
/* don't try to do i/o if one side couldn't be opened, as it hangs */
|
||||
if (hFile != INVALID_HANDLE_VALUE) {
|
||||
|
||||
/* see what happens if server calls DisconnectNamedPipe
|
||||
* when there are bytes in the pipe
|
||||
*/
|
||||
|
||||
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
|
||||
ok(written == sizeof(obuf), "write file len\n");
|
||||
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe while messages waiting\n");
|
||||
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL) == 0
|
||||
&& GetLastError() == ERROR_PIPE_NOT_CONNECTED, "WriteFile to disconnected pipe\n");
|
||||
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0
|
||||
&& GetLastError() == ERROR_PIPE_NOT_CONNECTED,
|
||||
"ReadFile from disconnected pipe with bytes waiting\n");
|
||||
ok(CloseHandle(hFile), "CloseHandle\n");
|
||||
}
|
||||
|
||||
ok(CloseHandle(hnp), "CloseHandle\n");
|
||||
|
||||
}
|
||||
|
||||
START_TEST(pipe)
|
||||
{
|
||||
trace("test 1 of 4:\n");
|
||||
test_DisconnectNamedPipe();
|
||||
trace("test 2 of 4:\n");
|
||||
test_CreateNamedPipe_instances_must_match();
|
||||
trace("test 3 of 4:\n");
|
||||
test_NamedPipe_2();
|
||||
trace("test 4 of 4:\n");
|
||||
test_CreateNamedPipe(PIPE_TYPE_BYTE);
|
||||
trace("all tests done\n");
|
||||
test_CreateNamedPipe(PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE);
|
||||
trace("all tests done\n");
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Unit tests for profile functions
|
||||
*
|
||||
* Copyright (c) 2003 Stefan Leichter
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "windows.h"
|
||||
|
||||
#define KEY "ProfileInt"
|
||||
#define SECTION "Test"
|
||||
#define TESTFILE ".\\testwine.ini"
|
||||
|
||||
struct _profileInt {
|
||||
LPCSTR section;
|
||||
LPCSTR key;
|
||||
LPCSTR value;
|
||||
LPCSTR iniFile;
|
||||
INT defaultVal;
|
||||
UINT result;
|
||||
};
|
||||
|
||||
static void test_profile_int(void)
|
||||
{
|
||||
struct _profileInt profileInt[]={
|
||||
{ NULL, NULL, NULL, NULL, 70, 0 }, /* 0 */
|
||||
{ NULL, NULL, NULL, TESTFILE, -1, 4294967295U},
|
||||
{ NULL, NULL, NULL, TESTFILE, 1, 1 },
|
||||
{ SECTION, NULL, NULL, TESTFILE, -1, 4294967295U},
|
||||
{ SECTION, NULL, NULL, TESTFILE, 1, 1 },
|
||||
{ NULL, KEY, NULL, TESTFILE, -1, 4294967295U}, /* 5 */
|
||||
{ NULL, KEY, NULL, TESTFILE, 1, 1 },
|
||||
{ SECTION, KEY, NULL, TESTFILE, -1, 4294967295U},
|
||||
{ SECTION, KEY, NULL, TESTFILE, 1, 1 },
|
||||
{ SECTION, KEY, "-1", TESTFILE, -1, 4294967295U},
|
||||
{ SECTION, KEY, "-1", TESTFILE, 1, 4294967295U}, /* 10 */
|
||||
{ SECTION, KEY, "1", TESTFILE, -1, 1 },
|
||||
{ SECTION, KEY, "1", TESTFILE, 1, 1 },
|
||||
{ SECTION, KEY, "+1", TESTFILE, -1, 1 },
|
||||
{ SECTION, KEY, "+1", TESTFILE, 1, 1 },
|
||||
{ SECTION, KEY, "4294967296", TESTFILE, -1, 0 }, /* 15 */
|
||||
{ SECTION, KEY, "4294967296", TESTFILE, 1, 0 },
|
||||
{ SECTION, KEY, "4294967297", TESTFILE, -1, 1 },
|
||||
{ SECTION, KEY, "4294967297", TESTFILE, 1, 1 },
|
||||
{ SECTION, KEY, "-4294967297", TESTFILE, -1, 4294967295U},
|
||||
{ SECTION, KEY, "-4294967297", TESTFILE, 1, 4294967295U}, /* 20 */
|
||||
{ SECTION, KEY, "42A94967297", TESTFILE, -1, 42 },
|
||||
{ SECTION, KEY, "42A94967297", TESTFILE, 1, 42 },
|
||||
{ SECTION, KEY, "B4294967297", TESTFILE, -1, 0 },
|
||||
{ SECTION, KEY, "B4294967297", TESTFILE, 1, 0 },
|
||||
};
|
||||
int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
|
||||
UINT res;
|
||||
|
||||
DeleteFileA( TESTFILE);
|
||||
|
||||
for (i=0; i < num_test; i++) {
|
||||
if (profileInt[i].value)
|
||||
WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value,
|
||||
profileInt[i].iniFile);
|
||||
|
||||
res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key,
|
||||
profileInt[i].defaultVal, profileInt[i].iniFile);
|
||||
ok(res == profileInt[i].result, "test<%02d>: ret<%010u> exp<%010u>\n",
|
||||
i, res, profileInt[i].result);
|
||||
}
|
||||
|
||||
DeleteFileA( TESTFILE);
|
||||
}
|
||||
|
||||
START_TEST(profile)
|
||||
{
|
||||
test_profile_int();
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/* Automatically generated file; DO NOT EDIT!! */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#if 0
|
||||
extern void func_alloc(void);
|
||||
#endif
|
||||
extern void func_atom(void);
|
||||
extern void func_change(void);
|
||||
extern void func_codepage(void);
|
||||
extern void func_comm(void);
|
||||
extern void func_console(void);
|
||||
extern void func_directory(void);
|
||||
extern void func_drive(void);
|
||||
extern void func_environ(void);
|
||||
extern void func_file(void);
|
||||
extern void func_format_msg(void);
|
||||
extern void func_heap(void);
|
||||
extern void func_locale(void);
|
||||
extern void func_mailslot(void);
|
||||
extern void func_path(void);
|
||||
extern void func_pipe(void);
|
||||
extern void func_process(void);
|
||||
extern void func_profile(void);
|
||||
extern void func_thread(void);
|
||||
extern void func_virtual(void);
|
||||
|
||||
struct test
|
||||
{
|
||||
const char *name;
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
static const struct test winetest_testlist[] =
|
||||
{
|
||||
#if 0
|
||||
{ "alloc", func_alloc },
|
||||
#endif
|
||||
{ "atom", func_atom },
|
||||
{ "change", func_change },
|
||||
{ "codepage", func_codepage },
|
||||
{ "comm", func_comm },
|
||||
{ "console", func_console },
|
||||
{ "directory", func_directory },
|
||||
{ "drive", func_drive },
|
||||
{ "environ", func_environ },
|
||||
{ "file", func_file },
|
||||
{ "format_msg", func_format_msg },
|
||||
{ "heap", func_heap },
|
||||
{ "locale", func_locale },
|
||||
{ "mailslot", func_mailslot },
|
||||
{ "path", func_path },
|
||||
{ "pipe", func_pipe },
|
||||
{ "process", func_process },
|
||||
{ "profile", func_profile },
|
||||
{ "thread", func_thread },
|
||||
{ "virtual", func_virtual },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
#define WINETEST_WANT_MAIN
|
||||
#include "wine/test.h"
|
|
@ -1,572 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for directory functions.
|
||||
*
|
||||
* Copyright 2002 Geoffrey Hausheer
|
||||
*
|
||||
* 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_WINNT to get SetThreadIdealProcessor on Windows */
|
||||
#define _WIN32_WINNT 0x0500
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winnt.h>
|
||||
#include <winerror.h>
|
||||
|
||||
/* Specify the number of simultaneous threads to test */
|
||||
#define NUM_THREADS 4
|
||||
/* Specify whether to test the extended priorities for Win2k/XP */
|
||||
#define USE_EXTENDED_PRIORITIES 0
|
||||
/* Specify whether to test the stack allocation in CreateThread */
|
||||
#define CHECK_STACK 0
|
||||
|
||||
/* Set CHECK_STACK to 1 if you want to try to test the stack-limit from
|
||||
CreateThread. So far I have been unable to make this work, and
|
||||
I am in doubt as to how portable it is. Also, according to MSDN,
|
||||
you shouldn't mix C-run-time-libraries (i.e. alloca) with CreateThread.
|
||||
Anyhow, the check is currently commented out
|
||||
*/
|
||||
#if CHECK_STACK
|
||||
#ifdef __try
|
||||
#define __TRY __try
|
||||
#define __EXCEPT __except
|
||||
#define __ENDTRY
|
||||
#else
|
||||
#include "wine/exception.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef BOOL (WINAPI *GetThreadPriorityBoost_t)(HANDLE,PBOOL);
|
||||
static GetThreadPriorityBoost_t pGetThreadPriorityBoost=NULL;
|
||||
|
||||
typedef HANDLE (WINAPI *OpenThread_t)(DWORD,BOOL,DWORD);
|
||||
static OpenThread_t pOpenThread=NULL;
|
||||
|
||||
typedef DWORD (WINAPI *SetThreadIdealProcessor_t)(HANDLE,DWORD);
|
||||
static SetThreadIdealProcessor_t pSetThreadIdealProcessor=NULL;
|
||||
|
||||
typedef BOOL (WINAPI *SetThreadPriorityBoost_t)(HANDLE,BOOL);
|
||||
static SetThreadPriorityBoost_t pSetThreadPriorityBoost=NULL;
|
||||
|
||||
/* Functions not tested yet:
|
||||
AttachThreadInput
|
||||
CreateRemoteThread
|
||||
SetThreadContext
|
||||
SwitchToThread
|
||||
|
||||
In addition there are no checks that the inheritance works properly in
|
||||
CreateThread
|
||||
*/
|
||||
|
||||
DWORD tlsIndex;
|
||||
|
||||
typedef struct {
|
||||
int threadnum;
|
||||
HANDLE *event;
|
||||
DWORD *threadmem;
|
||||
} t1Struct;
|
||||
|
||||
/* Basic test that simulatneous threads can access shared memory,
|
||||
that the thread local storage routines work correctly, and that
|
||||
threads actually run concurrently
|
||||
*/
|
||||
VOID WINAPI threadFunc1(t1Struct *tstruct)
|
||||
{
|
||||
int i;
|
||||
/* write our thread # into shared memory */
|
||||
tstruct->threadmem[tstruct->threadnum]=GetCurrentThreadId();
|
||||
ok(TlsSetValue(tlsIndex,(LPVOID)(tstruct->threadnum+1))!=0,
|
||||
"TlsSetValue failed\n");
|
||||
/* The threads synchronize before terminating. This is done by
|
||||
Signaling an event, and waiting for all events to occur
|
||||
*/
|
||||
SetEvent(tstruct->event[tstruct->threadnum]);
|
||||
WaitForMultipleObjects(NUM_THREADS,tstruct->event,TRUE,INFINITE);
|
||||
/* Double check that all threads really did run by validating that
|
||||
they have all written to the shared memory. There should be no race
|
||||
here, since all threads were synchronized after the write.*/
|
||||
for(i=0;i<NUM_THREADS;i++) {
|
||||
while(tstruct->threadmem[i]==0) ;
|
||||
}
|
||||
/* Check that noone cahnged our tls memory */
|
||||
ok((int)TlsGetValue(tlsIndex)-1==tstruct->threadnum,
|
||||
"TlsGetValue failed\n");
|
||||
ExitThread(NUM_THREADS+tstruct->threadnum);
|
||||
}
|
||||
|
||||
VOID WINAPI threadFunc2()
|
||||
{
|
||||
ExitThread(99);
|
||||
}
|
||||
|
||||
VOID WINAPI threadFunc3()
|
||||
{
|
||||
HANDLE thread;
|
||||
thread=GetCurrentThread();
|
||||
SuspendThread(thread);
|
||||
ExitThread(99);
|
||||
}
|
||||
|
||||
VOID WINAPI threadFunc4(HANDLE event)
|
||||
{
|
||||
if(event != NULL) {
|
||||
SetEvent(event);
|
||||
}
|
||||
Sleep(99000);
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
#if CHECK_STACK
|
||||
VOID WINAPI threadFunc5(DWORD *exitCode)
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
sysInfo.dwPageSize=0;
|
||||
GetSystemInfo(&sysInfo);
|
||||
*exitCode=0;
|
||||
__TRY
|
||||
{
|
||||
alloca(2*sysInfo.dwPageSize);
|
||||
}
|
||||
__EXCEPT(1) {
|
||||
*exitCode=1;
|
||||
}
|
||||
__ENDTRY
|
||||
ExitThread(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check basic funcationality of CreateThread and Tls* functions */
|
||||
VOID test_CreateThread_basic()
|
||||
{
|
||||
HANDLE thread[NUM_THREADS],event[NUM_THREADS];
|
||||
DWORD threadid[NUM_THREADS],curthreadId;
|
||||
DWORD threadmem[NUM_THREADS];
|
||||
DWORD exitCode;
|
||||
t1Struct tstruct[NUM_THREADS];
|
||||
int error;
|
||||
DWORD i,j;
|
||||
/* Retrieve current Thread ID for later comparisons */
|
||||
curthreadId=GetCurrentThreadId();
|
||||
/* Allocate some local storage */
|
||||
ok((tlsIndex=TlsAlloc())!=TLS_OUT_OF_INDEXES,"TlsAlloc failed\n");
|
||||
/* Create events for thread synchronization */
|
||||
for(i=0;i<NUM_THREADS;i++) {
|
||||
threadmem[i]=0;
|
||||
/* Note that it doesn't matter what type of event we chose here. This
|
||||
test isn't trying to thoroughly test events
|
||||
*/
|
||||
event[i]=CreateEventA(NULL,TRUE,FALSE,NULL);
|
||||
tstruct[i].threadnum=i;
|
||||
tstruct[i].threadmem=threadmem;
|
||||
tstruct[i].event=event;
|
||||
}
|
||||
|
||||
/* Test that passing arguments to threads works okay */
|
||||
for(i=0;i<NUM_THREADS;i++) {
|
||||
thread[i] = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc1,
|
||||
&tstruct[i],0,&threadid[i]);
|
||||
ok(thread[i]!=NULL,"Create Thread failed\n");
|
||||
}
|
||||
/* Test that the threads actually complete */
|
||||
for(i=0;i<NUM_THREADS;i++) {
|
||||
error=WaitForSingleObject(thread[i],5000);
|
||||
ok(error==WAIT_OBJECT_0, "Thread did not complete within timelimit\n");
|
||||
if(error!=WAIT_OBJECT_0) {
|
||||
TerminateThread(thread[i],i+NUM_THREADS);
|
||||
}
|
||||
ok(GetExitCodeThread(thread[i],&exitCode),"Could not retrieve ext code\n");
|
||||
ok(exitCode==i+NUM_THREADS,"Thread returned an incorrect exit code\n");
|
||||
}
|
||||
/* Test that each thread executed in its parent's address space
|
||||
(it was able to change threadmem and pass that change back to its parent)
|
||||
and that each thread id was independant). Note that we prove that the
|
||||
threads actually execute concurrently by having them block on each other
|
||||
in threadFunc1
|
||||
*/
|
||||
for(i=0;i<NUM_THREADS;i++) {
|
||||
error=0;
|
||||
for(j=i+1;j<NUM_THREADS;j++) {
|
||||
if (threadmem[i]==threadmem[j]) {
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
ok(!error && threadmem[i]==threadid[i] && threadmem[i]!=curthreadId,
|
||||
"Thread did not execute successfully\n");
|
||||
ok(CloseHandle(thread[i])!=0,"CloseHandle failed\n");
|
||||
}
|
||||
ok(TlsFree(tlsIndex)!=0,"TlsFree failed\n");
|
||||
}
|
||||
|
||||
/* Check that using the CREATE_SUSPENDED flag works */
|
||||
VOID test_CreateThread_suspended()
|
||||
{
|
||||
HANDLE thread;
|
||||
DWORD threadId;
|
||||
int error;
|
||||
|
||||
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc2,NULL,
|
||||
CREATE_SUSPENDED,&threadId);
|
||||
ok(thread!=NULL,"Create Thread failed\n");
|
||||
/* Check that the thread is suspended */
|
||||
ok(SuspendThread(thread)==1,"Thread did not start suspended\n");
|
||||
ok(ResumeThread(thread)==2,"Resume thread returned an invalid value\n");
|
||||
/* Check that resume thread didn't actually start the thread. I can't think
|
||||
of a better way of checking this than just waiting. I am not sure if this
|
||||
will work on slow computers.
|
||||
*/
|
||||
ok(WaitForSingleObject(thread,1000)==WAIT_TIMEOUT,
|
||||
"ResumeThread should not have actually started the thread\n");
|
||||
/* Now actually resume the thread and make sure that it actually completes*/
|
||||
ok(ResumeThread(thread)==1,"Resume thread returned an invalid value\n");
|
||||
ok((error=WaitForSingleObject(thread,1000))==WAIT_OBJECT_0,
|
||||
"Thread did not resume\n");
|
||||
if(error!=WAIT_OBJECT_0) {
|
||||
TerminateThread(thread,1);
|
||||
}
|
||||
ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
|
||||
}
|
||||
|
||||
/* Check that SuspendThread and ResumeThread work */
|
||||
VOID test_SuspendThread()
|
||||
{
|
||||
HANDLE thread,access_thread;
|
||||
DWORD threadId,exitCode;
|
||||
int i,error;
|
||||
|
||||
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc3,NULL,
|
||||
0,&threadId);
|
||||
ok(thread!=NULL,"Create Thread failed\n");
|
||||
/* Check that the thread is suspended */
|
||||
/* Note that this is a polling method, and there is a race between
|
||||
SuspendThread being called (in the child, and the loop below timing out,
|
||||
so the test could fail on a heavily loaded or slow computer.
|
||||
*/
|
||||
error=0;
|
||||
for(i=0;error==0 && i<100;i++) {
|
||||
error=SuspendThread(thread);
|
||||
ResumeThread(thread);
|
||||
if(error==0) {
|
||||
Sleep(50);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
ok(error==1,"SuspendThread did not work\n");
|
||||
/* check that access restrictions are obeyed */
|
||||
if (pOpenThread) {
|
||||
access_thread=pOpenThread(THREAD_ALL_ACCESS & (~THREAD_SUSPEND_RESUME),
|
||||
0,threadId);
|
||||
ok(access_thread!=NULL,"OpenThread returned an invalid handle\n");
|
||||
if (access_thread!=NULL) {
|
||||
ok(SuspendThread(access_thread)==-1,
|
||||
"SuspendThread did not obey access restrictions\n");
|
||||
ok(ResumeThread(access_thread)==-1,
|
||||
"ResumeThread did not obey access restrictions\n");
|
||||
ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n");
|
||||
}
|
||||
}
|
||||
/* Double check that the thread really is suspended */
|
||||
ok((error=GetExitCodeThread(thread,&exitCode))!=0 && exitCode==STILL_ACTIVE,
|
||||
"Thread did not really suspend\n");
|
||||
/* Resume the thread, and make sure it actually completes */
|
||||
ok(ResumeThread(thread)==1,"Resume thread returned an invalid value\n");
|
||||
ok((error=WaitForSingleObject(thread,1000))==WAIT_OBJECT_0,
|
||||
"Thread did not resume\n");
|
||||
if(error!=WAIT_OBJECT_0) {
|
||||
TerminateThread(thread,1);
|
||||
}
|
||||
/* Trying to suspend a terminated thread should fail */
|
||||
error=SuspendThread(thread);
|
||||
ok(error==0xffffffff, "wrong return code: %d\n", error);
|
||||
ok(GetLastError()==ERROR_ACCESS_DENIED || GetLastError()==ERROR_NO_MORE_ITEMS, "unexpected error code: %ld\n", GetLastError());
|
||||
|
||||
ok(CloseHandle(thread)!=0,"CloseHandle Failed\n");
|
||||
}
|
||||
|
||||
/* Check that TerminateThread works properly
|
||||
*/
|
||||
VOID test_TerminateThread()
|
||||
{
|
||||
HANDLE thread,access_thread,event;
|
||||
DWORD threadId,exitCode;
|
||||
int i,error;
|
||||
i=0; error=0;
|
||||
event=CreateEventA(NULL,TRUE,FALSE,NULL);
|
||||
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc4,
|
||||
(LPVOID)event, 0,&threadId);
|
||||
ok(thread!=NULL,"Create Thread failed\n");
|
||||
/* Terminate thread has a race condition in Wine. If the thread is terminated
|
||||
before it starts, it leaves a process behind. Therefore, we wait for the
|
||||
thread to signal that it has started. There is no easy way to force the
|
||||
race to occur, so we don't try to find it.
|
||||
*/
|
||||
ok(WaitForSingleObject(event,5000)==WAIT_OBJECT_0,
|
||||
"TerminateThread didn't work\n");
|
||||
/* check that access restrictions are obeyed */
|
||||
if (pOpenThread) {
|
||||
access_thread=pOpenThread(THREAD_ALL_ACCESS & (~THREAD_TERMINATE),
|
||||
0,threadId);
|
||||
ok(access_thread!=NULL,"OpenThread returned an invalid handle\n");
|
||||
if (access_thread!=NULL) {
|
||||
ok(TerminateThread(access_thread,99)==0,
|
||||
"TerminateThread did not obey access restrictions\n");
|
||||
ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n");
|
||||
}
|
||||
}
|
||||
/* terminate a job and make sure it terminates */
|
||||
ok(TerminateThread(thread,99)!=0,"TerminateThread failed\n");
|
||||
ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0,
|
||||
"TerminateThread didn't work\n");
|
||||
ok(GetExitCodeThread(thread,&exitCode)!=STILL_ACTIVE,
|
||||
"TerminateThread should not leave the thread 'STILL_ACTIVE'\n");
|
||||
ok(exitCode==99, "TerminateThread returned invalid exit code\n");
|
||||
ok(CloseHandle(thread)!=0,"Error Closing thread handle\n");
|
||||
}
|
||||
|
||||
/* Check if CreateThread obeys the specified stack size. This code does
|
||||
not work properly, and is currently disabled
|
||||
*/
|
||||
VOID test_CreateThread_stack()
|
||||
{
|
||||
#if CHECK_STACK
|
||||
/* The only way I know of to test the stack size is to use alloca
|
||||
and __try/__except. However, this is probably not portable,
|
||||
and I couldn't get it to work under Wine anyhow. However, here
|
||||
is the code which should allow for testing that CreateThread
|
||||
respects the stack-size limit
|
||||
*/
|
||||
HANDLE thread;
|
||||
DWORD threadId,exitCode;
|
||||
|
||||
SYSTEM_INFO sysInfo;
|
||||
sysInfo.dwPageSize=0;
|
||||
GetSystemInfo(&sysInfo);
|
||||
ok(sysInfo.dwPageSize>0,"GetSystemInfo should return a valid page size\n");
|
||||
thread = CreateThread(NULL,sysInfo.dwPageSize,
|
||||
(LPTHREAD_START_ROUTINE)threadFunc5,&exitCode,
|
||||
0,&threadId);
|
||||
ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0,
|
||||
"TerminateThread didn't work\n");
|
||||
ok(exitCode==1,"CreateThread did not obey stack-size-limit\n");
|
||||
ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check whether setting/retrieving thread priorities works */
|
||||
VOID test_thread_priority()
|
||||
{
|
||||
HANDLE curthread,access_thread;
|
||||
DWORD curthreadId,exitCode;
|
||||
int min_priority=-2,max_priority=2;
|
||||
BOOL disabled;
|
||||
int i;
|
||||
|
||||
curthread=GetCurrentThread();
|
||||
curthreadId=GetCurrentThreadId();
|
||||
/* Check thread priority */
|
||||
/* NOTE: on Win2k/XP priority can be from -7 to 6. All other platforms it
|
||||
is -2 to 2. However, even on a real Win2k system, using thread
|
||||
priorities beyond the -2 to 2 range does not work. If you want to try
|
||||
anyway, enable USE_EXTENDED_PRIORITIES
|
||||
*/
|
||||
ok(GetThreadPriority(curthread)==THREAD_PRIORITY_NORMAL,
|
||||
"GetThreadPriority Failed\n");
|
||||
|
||||
if (pOpenThread) {
|
||||
/* check that access control is obeyed */
|
||||
access_thread=pOpenThread(THREAD_ALL_ACCESS &
|
||||
(~THREAD_QUERY_INFORMATION) & (~THREAD_SET_INFORMATION),
|
||||
0,curthreadId);
|
||||
ok(access_thread!=NULL,"OpenThread returned an invalid handle\n");
|
||||
if (access_thread!=NULL) {
|
||||
ok(SetThreadPriority(access_thread,1)==0,
|
||||
"SetThreadPriority did not obey access restrictions\n");
|
||||
ok(GetThreadPriority(access_thread)==THREAD_PRIORITY_ERROR_RETURN,
|
||||
"GetThreadPriority did not obey access restrictions\n");
|
||||
if (pSetThreadPriorityBoost)
|
||||
ok(pSetThreadPriorityBoost(access_thread,1)==0,
|
||||
"SetThreadPriorityBoost did not obey access restrictions\n");
|
||||
if (pGetThreadPriorityBoost)
|
||||
ok(pGetThreadPriorityBoost(access_thread,&disabled)==0,
|
||||
"GetThreadPriorityBoost did not obey access restrictions\n");
|
||||
ok(GetExitCodeThread(access_thread,&exitCode)==0,
|
||||
"GetExitCodeThread did not obey access restrictions\n");
|
||||
ok(CloseHandle(access_thread),"Error Closing thread handle\n");
|
||||
}
|
||||
#if USE_EXTENDED_PRIORITIES
|
||||
min_priority=-7; max_priority=6;
|
||||
#endif
|
||||
}
|
||||
for(i=min_priority;i<=max_priority;i++) {
|
||||
ok(SetThreadPriority(curthread,i)!=0,
|
||||
"SetThreadPriority Failed for priority: %d\n",i);
|
||||
ok(GetThreadPriority(curthread)==i,
|
||||
"GetThreadPriority Failed for priority: %d\n",i);
|
||||
}
|
||||
ok(SetThreadPriority(curthread,THREAD_PRIORITY_TIME_CRITICAL)!=0,
|
||||
"SetThreadPriority Failed\n");
|
||||
ok(GetThreadPriority(curthread)==THREAD_PRIORITY_TIME_CRITICAL,
|
||||
"GetThreadPriority Failed\n");
|
||||
ok(SetThreadPriority(curthread,THREAD_PRIORITY_IDLE)!=0,
|
||||
"SetThreadPriority Failed\n");
|
||||
ok(GetThreadPriority(curthread)==THREAD_PRIORITY_IDLE,
|
||||
"GetThreadPriority Failed\n");
|
||||
ok(SetThreadPriority(curthread,0)!=0,"SetThreadPriority Failed\n");
|
||||
|
||||
/* Check thread priority boost */
|
||||
if (pGetThreadPriorityBoost && pSetThreadPriorityBoost) {
|
||||
BOOL rc;
|
||||
todo_wine {
|
||||
SetLastError(0);
|
||||
rc=pGetThreadPriorityBoost(curthread,&disabled);
|
||||
if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
ok(rc!=0,"error=%ld\n",GetLastError());
|
||||
|
||||
ok(pSetThreadPriorityBoost(curthread,1)!=0,
|
||||
"error=%ld\n",GetLastError());
|
||||
rc=pGetThreadPriorityBoost(curthread,&disabled);
|
||||
ok(rc!=0 && disabled==1,
|
||||
"rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
|
||||
|
||||
ok(pSetThreadPriorityBoost(curthread,0)!=0,
|
||||
"error=%ld\n",GetLastError());
|
||||
rc=pGetThreadPriorityBoost(curthread,&disabled);
|
||||
ok(rc!=0 && disabled==0,
|
||||
"rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check the GetThreadTimes function */
|
||||
VOID test_GetThreadTimes()
|
||||
{
|
||||
HANDLE thread,access_thread=NULL;
|
||||
FILETIME creationTime,exitTime,kernelTime,userTime;
|
||||
DWORD threadId;
|
||||
int error;
|
||||
|
||||
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc2,NULL,
|
||||
CREATE_SUSPENDED,&threadId);
|
||||
|
||||
ok(thread!=NULL,"Create Thread failed\n");
|
||||
/* check that access control is obeyed */
|
||||
if (pOpenThread) {
|
||||
access_thread=pOpenThread(THREAD_ALL_ACCESS &
|
||||
(~THREAD_QUERY_INFORMATION), 0,threadId);
|
||||
ok(access_thread!=NULL,
|
||||
"OpenThread returned an invalid handle\n");
|
||||
}
|
||||
ok(ResumeThread(thread)==1,"Resume thread returned an invalid value\n");
|
||||
ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0,
|
||||
"ResumeThread didn't work\n");
|
||||
if(access_thread!=NULL) {
|
||||
error=GetThreadTimes(access_thread,&creationTime,&exitTime,
|
||||
&kernelTime,&userTime);
|
||||
ok(error==0, "GetThreadTimes did not obey access restrictions\n");
|
||||
ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n");
|
||||
}
|
||||
creationTime.dwLowDateTime=99; creationTime.dwHighDateTime=99;
|
||||
exitTime.dwLowDateTime=99; exitTime.dwHighDateTime=99;
|
||||
kernelTime.dwLowDateTime=99; kernelTime.dwHighDateTime=99;
|
||||
userTime.dwLowDateTime=99; userTime.dwHighDateTime=99;
|
||||
/* GetThreadTimes should set all of the parameters passed to it */
|
||||
error=GetThreadTimes(thread,&creationTime,&exitTime,
|
||||
&kernelTime,&userTime);
|
||||
if (error!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
ok(error!=0,"GetThreadTimes failed\n");
|
||||
ok(creationTime.dwLowDateTime!=99 || creationTime.dwHighDateTime!=99,
|
||||
"creationTime was invalid\n");
|
||||
ok(exitTime.dwLowDateTime!=99 || exitTime.dwHighDateTime!=99,
|
||||
"exitTime was invalid\n");
|
||||
ok(kernelTime.dwLowDateTime!=99 || kernelTime.dwHighDateTime!=99,
|
||||
"kernelTimewas invalid\n");
|
||||
ok(userTime.dwLowDateTime!=99 || userTime.dwHighDateTime!=99,
|
||||
"userTime was invalid\n");
|
||||
ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the processor affinity functions */
|
||||
/* NOTE: These functions should also be checked that they obey access control
|
||||
*/
|
||||
VOID test_thread_processor()
|
||||
{
|
||||
HANDLE curthread,curproc;
|
||||
DWORD processMask,systemMask;
|
||||
SYSTEM_INFO sysInfo;
|
||||
int error=0;
|
||||
|
||||
sysInfo.dwNumberOfProcessors=0;
|
||||
GetSystemInfo(&sysInfo);
|
||||
ok(sysInfo.dwNumberOfProcessors>0,
|
||||
"GetSystemInfo failed to return a valid # of processors\n");
|
||||
/* Use the current Thread/process for all tests */
|
||||
curthread=GetCurrentThread();
|
||||
ok(curthread!=NULL,"GetCurrentThread failed\n");
|
||||
curproc=GetCurrentProcess();
|
||||
ok(curproc!=NULL,"GetCurrentProcess failed\n");
|
||||
/* Check the Affinity Mask functions */
|
||||
ok(GetProcessAffinityMask(curproc,&processMask,&systemMask)!=0,
|
||||
"GetProcessAffinityMask failed\n");
|
||||
ok(SetThreadAffinityMask(curthread,processMask)==1,
|
||||
"SetThreadAffinityMask failed\n");
|
||||
ok(SetThreadAffinityMask(curthread,processMask+1)==0,
|
||||
"SetThreadAffinityMask passed for an illegal processor\n");
|
||||
/* NOTE: This only works on WinNT/2000/XP) */
|
||||
if (pSetThreadIdealProcessor) {
|
||||
todo_wine {
|
||||
SetLastError(0);
|
||||
error=pSetThreadIdealProcessor(curthread,0);
|
||||
if (GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
ok(error!=-1, "SetThreadIdealProcessor failed\n");
|
||||
}
|
||||
}
|
||||
if (GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS+1);
|
||||
ok(error==-1,
|
||||
"SetThreadIdealProcessor succeeded with an illegal processor #\n");
|
||||
todo_wine {
|
||||
error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS);
|
||||
ok(error==0, "SetThreadIdealProcessor returned an incorrect value\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(thread)
|
||||
{
|
||||
HINSTANCE lib;
|
||||
/* Neither Cygwin nor mingW export OpenThread, so do a dynamic check
|
||||
so that the compile passes
|
||||
*/
|
||||
lib=LoadLibraryA("kernel32");
|
||||
ok(lib!=NULL,"Couldn't load kernel32.dll\n");
|
||||
pGetThreadPriorityBoost=(GetThreadPriorityBoost_t)GetProcAddress(lib,"GetThreadPriorityBoost");
|
||||
pOpenThread=(OpenThread_t)GetProcAddress(lib,"OpenThread");
|
||||
pSetThreadIdealProcessor=(SetThreadIdealProcessor_t)GetProcAddress(lib,"SetThreadIdealProcessor");
|
||||
pSetThreadPriorityBoost=(SetThreadPriorityBoost_t)GetProcAddress(lib,"SetThreadPriorityBoost");
|
||||
test_CreateThread_basic();
|
||||
test_CreateThread_suspended();
|
||||
test_SuspendThread();
|
||||
test_TerminateThread();
|
||||
test_CreateThread_stack();
|
||||
test_thread_priority();
|
||||
test_GetThreadTimes();
|
||||
test_thread_processor();
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for time functions
|
||||
*
|
||||
* Copyright 2004 Uwe Bonnes
|
||||
*
|
||||
* 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 "wine/test.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#define SECSPERMIN 60
|
||||
#define SECSPERDAY 86400
|
||||
/* 1601 to 1970 is 369 years plus 89 leap days */
|
||||
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
|
||||
#define TICKSPERSEC 10000000
|
||||
#define TICKSPERMSEC 10000
|
||||
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
|
||||
|
||||
|
||||
void test_GetTimeZoneInformation()
|
||||
{
|
||||
TIME_ZONE_INFORMATION tzinfo, tzinfo1;
|
||||
DWORD res = GetTimeZoneInformation(&tzinfo);
|
||||
ok(res != 0, "GetTimeZoneInformation failed\n");
|
||||
ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
|
||||
"SetEnvironmentVariableA failed\n");
|
||||
res = GetTimeZoneInformation(&tzinfo1);
|
||||
ok(res != 0, "GetTimeZoneInformation failed\n");
|
||||
|
||||
ok(((tzinfo.Bias == tzinfo1.Bias) &&
|
||||
(tzinfo.StandardBias == tzinfo1.StandardBias) &&
|
||||
(tzinfo.DaylightBias == tzinfo1.DaylightBias)),
|
||||
"Bias influenced by TZ variable\n");
|
||||
ok(SetEnvironmentVariableA("TZ",NULL) != 0,
|
||||
"SetEnvironmentVariableA failed\n");
|
||||
|
||||
}
|
||||
|
||||
void test_FileTimeToSystemTime()
|
||||
{
|
||||
FILETIME ft;
|
||||
SYSTEMTIME st;
|
||||
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
|
||||
|
||||
ft.dwHighDateTime = 0;
|
||||
ft.dwLowDateTime = 0;
|
||||
ok(FileTimeToSystemTime(&ft, &st),
|
||||
"FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
|
||||
ok(((st.wYear == 1601) && (st.wMonth == 1) && (st.wDay == 1) &&
|
||||
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 0) &&
|
||||
(st.wMilliseconds == 0)),
|
||||
"Got Year %4d Month %2d Day %2d\n", st.wYear, st.wMonth, st.wDay);
|
||||
|
||||
ft.dwHighDateTime = (UINT)(time >> 32);
|
||||
ft.dwLowDateTime = (UINT)time;
|
||||
ok(FileTimeToSystemTime(&ft, &st),
|
||||
"FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
|
||||
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
|
||||
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
|
||||
(st.wMilliseconds == 0)),
|
||||
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
|
||||
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
|
||||
st.wMilliseconds);
|
||||
}
|
||||
|
||||
void test_FileTimeToLocalFileTime()
|
||||
{
|
||||
FILETIME ft, lft;
|
||||
SYSTEMTIME st;
|
||||
TIME_ZONE_INFORMATION tzinfo;
|
||||
DWORD res = GetTimeZoneInformation(&tzinfo);
|
||||
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970
|
||||
+ (ULONGLONG)tzinfo.Bias*SECSPERMIN *TICKSPERSEC;
|
||||
|
||||
ok( res != 0, "GetTimeZoneInformation failed\n");
|
||||
ft.dwHighDateTime = (UINT)(time >> 32);
|
||||
ft.dwLowDateTime = (UINT)time;
|
||||
ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
|
||||
"FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
|
||||
FileTimeToSystemTime(&lft, &st);
|
||||
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
|
||||
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
|
||||
(st.wMilliseconds == 0)),
|
||||
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
|
||||
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
|
||||
st.wMilliseconds);
|
||||
|
||||
ok(SetEnvironmentVariableA("TZ","GMT") != 0,
|
||||
"SetEnvironmentVariableA failed\n");
|
||||
ok(res != 0, "GetTimeZoneInformation failed\n");
|
||||
ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
|
||||
"FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
|
||||
FileTimeToSystemTime(&lft, &st);
|
||||
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
|
||||
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
|
||||
(st.wMilliseconds == 0)),
|
||||
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
|
||||
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
|
||||
st.wMilliseconds);
|
||||
ok(SetEnvironmentVariableA("TZ",NULL) != 0,
|
||||
"SetEnvironmentVariableA failed\n");
|
||||
}
|
||||
|
||||
START_TEST(time)
|
||||
{
|
||||
test_GetTimeZoneInformation();
|
||||
test_FileTimeToSystemTime();
|
||||
test_FileTimeToLocalFileTime();
|
||||
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for Virtual* family of APIs.
|
||||
*
|
||||
* Copyright 2004 Dmitry Timoshkov
|
||||
*
|
||||
* 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 <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static void test_VirtualAlloc(void)
|
||||
{
|
||||
void *addr1, *addr2;
|
||||
DWORD old_prot;
|
||||
MEMORY_BASIC_INFORMATION info;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS);
|
||||
ok(addr1 == NULL, "VirtualAlloc should fail on zero-sized allocation\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
|
||||
GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
|
||||
"got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
|
||||
|
||||
addr1 = VirtualAlloc(0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
|
||||
ok(addr1 != NULL, "VirtualAlloc failed\n");
|
||||
|
||||
/* test a not committed memory */
|
||||
ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
|
||||
"VirtualQuery failed\n");
|
||||
ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
|
||||
ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
|
||||
ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
|
||||
ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
|
||||
ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
|
||||
/* NT reports Protect == 0 for a not committed memory block */
|
||||
ok(info.Protect == 0 /* NT */ ||
|
||||
info.Protect == PAGE_NOACCESS, /* Win9x */
|
||||
"%lx != PAGE_NOACCESS\n", info.Protect);
|
||||
ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
|
||||
"VirtualProtect should fail on a not committed memory\n");
|
||||
ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
|
||||
"got %ld, expected ERROR_INVALID_ADDRESS\n", GetLastError());
|
||||
|
||||
addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
|
||||
ok(addr1 == addr2, "VirtualAlloc failed\n");
|
||||
|
||||
/* test a committed memory */
|
||||
ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
|
||||
"VirtualQuery failed\n");
|
||||
ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
|
||||
ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
|
||||
ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
|
||||
ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
|
||||
ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
|
||||
/* this time NT reports PAGE_NOACCESS as well */
|
||||
ok(info.Protect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.Protect);
|
||||
ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
|
||||
|
||||
/* this should fail, since not the whole range is committed yet */
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
|
||||
"VirtualProtect should fail on a not committed memory\n");
|
||||
ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
|
||||
"got %ld, expected ERROR_INVALID_ADDRESS\n", GetLastError());
|
||||
|
||||
ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n");
|
||||
ok(old_prot == PAGE_NOACCESS,
|
||||
"wrong old protection: got %04lx instead of PAGE_NOACCESS\n", old_prot);
|
||||
|
||||
ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n");
|
||||
ok(old_prot == PAGE_READONLY,
|
||||
"wrong old protection: got %04lx instead of PAGE_READONLY\n", old_prot);
|
||||
|
||||
ok(!VirtualFree(addr1, 0x10000, 0), "VirtualFree should fail with type 0\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
|
||||
|
||||
ok(VirtualFree(addr1, 0x10000, MEM_DECOMMIT), "VirtualFree failed\n");
|
||||
|
||||
/* if the type is MEM_RELEASE, size must be 0 */
|
||||
ok(!VirtualFree(addr1, 1, MEM_RELEASE), "VirtualFree should fail\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
|
||||
|
||||
ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
|
||||
}
|
||||
|
||||
START_TEST(virtual)
|
||||
{
|
||||
test_VirtualAlloc();
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <net/lan.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <rosrtl/string.h>
|
||||
|
||||
using std::string;
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
void display_row( char *data, int off, int len ) {
|
||||
int i;
|
||||
|
||||
printf( "%08x:", off );
|
||||
for( i = off; i < len && i < off + 16; i++ ) {
|
||||
printf( " %02x", data[i] & 0xff );
|
||||
}
|
||||
|
||||
for( ; i < off + 16; i++ )
|
||||
printf(" ");
|
||||
|
||||
printf( " -- " );
|
||||
|
||||
for( i = off; i < len && i < off + 16; i++ ) {
|
||||
printf( "%c", (data[i] >= ' ' && data[i] <= '~') ? data[i] : '.' );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void display_buffer( char *Packet, int ReadLen ) {
|
||||
UINT PktLen;
|
||||
for( PktLen = 0; PktLen < ReadLen; PktLen += 16 )
|
||||
display_row( Packet, PktLen, ReadLen );
|
||||
}
|
||||
|
||||
int byte_till_end( char *Packet, int PktLen ) {
|
||||
int byte;
|
||||
std::string word;
|
||||
|
||||
cin >> word;
|
||||
while( word != "end" ) {
|
||||
byte = strtoul( (string("0x") + word).c_str(), 0, 0 );
|
||||
fprintf( stderr, "Byte[%d]: %x\n", PktLen, byte & 0xff );
|
||||
Packet[PktLen++] = byte;
|
||||
cin >> word;
|
||||
}
|
||||
|
||||
return PktLen;
|
||||
}
|
||||
|
||||
/* Ethernet types. We swap constants so we can compare values at runtime
|
||||
without swapping them there */
|
||||
#define ETYPE_IPv4 WH2N(0x0800)
|
||||
#define ETYPE_IPv6 WH2N(0x86DD)
|
||||
#define ETYPE_ARP WH2N(0x0806)
|
||||
|
||||
extern "C"
|
||||
NTSTATUS STDCALL NtCreateFile(
|
||||
PHANDLE FileHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PLARGE_INTEGER AllocationSize,
|
||||
ULONG FileAttributes,
|
||||
ULONG ShareAccess,
|
||||
ULONG CreateDisposition,
|
||||
ULONG CreateOptions,
|
||||
PVOID EaBuffer,
|
||||
ULONG EaLength);
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
string word;
|
||||
HANDLE LanFile;
|
||||
OBJECT_ATTRIBUTES Attributes;
|
||||
UNICODE_STRING LanDevice;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
HANDLE Event;
|
||||
PFILE_FULL_EA_INFORMATION EaBuffer;
|
||||
NTSTATUS Status;
|
||||
DWORD On = 1, PktLen;
|
||||
CHAR Packet[1600];
|
||||
PLAN_PACKET_HEADER Hdr = (PLAN_PACKET_HEADER)Packet;
|
||||
PLAN_ADDRESS Addr = (PLAN_ADDRESS)Packet;
|
||||
USHORT TypesToListen[] = { ETYPE_IPv4, ETYPE_IPv6, ETYPE_ARP };
|
||||
UINT EaLength = LAN_EA_INFO_SIZE(sizeof(TypesToListen)/sizeof(USHORT));
|
||||
|
||||
Status = NtCreateEvent(&Event,
|
||||
EVENT_ALL_ACCESS,
|
||||
NULL,
|
||||
0,
|
||||
0 );
|
||||
|
||||
RtlInitUnicodeString( &LanDevice, L"\\Device\\Lan" );
|
||||
|
||||
InitializeObjectAttributes( &Attributes,
|
||||
&LanDevice,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL );
|
||||
|
||||
EaBuffer = (PFILE_FULL_EA_INFORMATION)calloc( EaLength, 1 );
|
||||
LAN_FILL_EA_INFO(EaBuffer,sizeof(TypesToListen)/sizeof(USHORT),
|
||||
TypesToListen);
|
||||
|
||||
Status = ZwCreateFile( &LanFile,
|
||||
SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE |
|
||||
GENERIC_EXECUTE,
|
||||
&Attributes,
|
||||
&Iosb,
|
||||
NULL,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_OPEN_IF,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT,
|
||||
EaBuffer,
|
||||
EaLength );
|
||||
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
cerr << "Could not open lan device " << Status << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Status = DeviceIoControl( LanFile,
|
||||
IOCTL_IF_BUFFERED_MODE,
|
||||
&On,
|
||||
sizeof(On),
|
||||
0,
|
||||
0,
|
||||
&PktLen,
|
||||
NULL );
|
||||
|
||||
if( !Status ) {
|
||||
cerr << "Could not turn on buffered mode " << Status << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
while( cin >> word ) {
|
||||
if( word == "end" ) {
|
||||
NtClose( LanFile );
|
||||
return 0;
|
||||
} else if( word == "enum" ) {
|
||||
Status = DeviceIoControl( LanFile,
|
||||
IOCTL_IF_ENUM_ADAPTERS,
|
||||
NULL,
|
||||
0,
|
||||
Packet,
|
||||
sizeof(Packet),
|
||||
&PktLen,
|
||||
NULL );
|
||||
|
||||
cout << "EnumAdapters: " << Status << "\n";
|
||||
if( Status )
|
||||
display_buffer( Packet, PktLen );
|
||||
} else if( word == "query" ) {
|
||||
cin >> PktLen;
|
||||
|
||||
Status = DeviceIoControl( LanFile,
|
||||
IOCTL_IF_ADAPTER_INFO,
|
||||
&PktLen,
|
||||
sizeof(PktLen),
|
||||
Packet,
|
||||
sizeof(Packet),
|
||||
&PktLen,
|
||||
NULL );
|
||||
|
||||
cout << "QueryAdapterInfo: " << Status << "\n";
|
||||
if( Status )
|
||||
display_buffer( Packet, PktLen );
|
||||
} else if( word == "send" ) {
|
||||
cin >> Hdr->Fixed.Adapter
|
||||
>> Hdr->Fixed.AddressType
|
||||
>> Hdr->Fixed.AddressLen
|
||||
>> Hdr->Fixed.PacketType;
|
||||
Hdr->Fixed.Mdl = NULL;
|
||||
PktLen = byte_till_end( Packet, Hdr->Address - (PCHAR)Hdr );
|
||||
Status = NtWriteFile( LanFile,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
Packet,
|
||||
PktLen,
|
||||
NULL,
|
||||
NULL );
|
||||
|
||||
cout << "NtWriteFile: " << Status << "\n";
|
||||
} else if( word == "recv" ) {
|
||||
ULONG ReadLen;
|
||||
Status = NtReadFile( LanFile,
|
||||
Event,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
Packet,
|
||||
sizeof(Packet),
|
||||
NULL,
|
||||
NULL );
|
||||
cout << "NtReadFile: " << Status << "\n";
|
||||
if( Status == STATUS_PENDING ) {
|
||||
LARGE_INTEGER Timeout = { 0 };
|
||||
Status = NtWaitForSingleObject( Event, 1, &Timeout );
|
||||
}
|
||||
|
||||
ReadLen = Iosb.Information;
|
||||
|
||||
if( Status == STATUS_SUCCESS ) {
|
||||
cout << "Read " << ReadLen << " bytes\n";
|
||||
display_buffer( Packet, ReadLen );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# $Id: makefile,v 1.1 2004/09/17 16:07:41 arty Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = lantest
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = lantest.o -lstdc++
|
||||
|
||||
TARGET_CPPFLAGS = -I$(PATH_TO_TOP)/include -g
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,54 +0,0 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
include $(PATH_TO_TOP)/config
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
SRV_OBJECTS= shmsrv.o
|
||||
CLT_OBJECTS= shmclt.o
|
||||
|
||||
PROGS= shmsrv.exe shmclt.exe
|
||||
|
||||
CFLAGS = $(STD_CFLAGS)
|
||||
|
||||
LIBS = $(SDK_PATH_LIB)/kernel32.a \
|
||||
$(SDK_PATH_LIB)/ntdll.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
implib:
|
||||
|
||||
clean:
|
||||
- $(RM) *.o *.exe *.sym
|
||||
|
||||
.phony: implib clean
|
||||
|
||||
ifneq ($(BOOTCD_INSTALL),)
|
||||
|
||||
install: $(PROGS:%=$(INSTALL_DIR)/%)
|
||||
|
||||
$(PROGS:%=$(INSTALL_DIR)/%): $(INSTALL_DIR)/%: %
|
||||
$(CP) $* $(INSTALL_DIR)/$*
|
||||
|
||||
else # BOOTCD_INSTALL
|
||||
|
||||
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
|
||||
|
||||
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
|
||||
$(CP) $* $(INSTALL_DIR)/bin/$*
|
||||
|
||||
endif # BOOTCD_INSTALL
|
||||
|
||||
shmsrv.exe: $(SRV_OBJECTS) $(LIBS)
|
||||
$(CC) $(SRV_OBJECTS) $(LIBS) -o shmsrv.exe
|
||||
$(NM) --numeric-sort shmsrv.exe > shmsrv.sym
|
||||
|
||||
shmclt.exe: $(CLT_OBJECTS) $(LIBS)
|
||||
$(CC) $(CLT_OBJECTS) $(LIBS) -o shmclt.exe
|
||||
$(NM) --numeric-sort shmsrv.exe > shmclt.sym
|
||||
|
||||
# EOF
|
|
@ -1,61 +0,0 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
char buffer[256];
|
||||
|
||||
printf("Shm test server\n");
|
||||
|
||||
Section = OpenFileMappingW (
|
||||
// PAGE_EXECUTE_READWRITE, invalid parameter
|
||||
FILE_MAP_WRITE,
|
||||
FALSE,
|
||||
L"TestSection"
|
||||
);
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to open section (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
8192);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section (err=%d)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("BaseAddress %x\n", (UINT) BaseAddress);
|
||||
printf("Copying from section\n");
|
||||
strcpy(buffer, BaseAddress);
|
||||
printf("Copyed <%s>\n", buffer);
|
||||
|
||||
// for(;;);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/* $Id: shmsrv.c,v 1.5 2000/06/29 23:35:10 dwelch Exp $
|
||||
*
|
||||
* FILE : reactos/apps/shm/shmsrv.c
|
||||
* AUTHOR: David Welch
|
||||
*/
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
|
||||
printf("Shm test server\n");
|
||||
|
||||
Section = CreateFileMappingW (
|
||||
(HANDLE) 0xFFFFFFFF,
|
||||
NULL,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
8192,
|
||||
L"TestSection"
|
||||
);
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to create section (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Mapping view of section\n");
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
8192);
|
||||
printf("BaseAddress %x\n", (UINT) BaseAddress);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section\n");
|
||||
}
|
||||
|
||||
printf("Copying to section\n");
|
||||
printf("Copying %s\n", GetCommandLineA());
|
||||
strcpy(BaseAddress, GetCommandLineA());
|
||||
|
||||
Sleep(INFINITE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,7 +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 = statst
|
||||
|
||||
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,165 +0,0 @@
|
|||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
static LPSTR STATIC_CLASS = "STATIC";
|
||||
static LPSTR TEST_WND_CLASS = "TESTWND";
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define DPRINT(s) (void)0
|
||||
#else
|
||||
#define DPRINT(s) OutputDebugStringA("STATICTEST: " s "\n")
|
||||
#endif
|
||||
|
||||
HINSTANCE AppInstance = NULL;
|
||||
|
||||
LRESULT WmCreate(
|
||||
HWND Wnd)
|
||||
{
|
||||
UCHAR i;
|
||||
DPRINT("WM_CREATE (enter).");
|
||||
// Test 1 - black rectangle.
|
||||
DPRINT("test 1");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE | SS_BLACKRECT,
|
||||
10, 10, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 2 - black frame.
|
||||
DPRINT("test 2");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE | SS_BLACKFRAME,
|
||||
10, 40, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 3 - gray rectangle.
|
||||
DPRINT("test 3");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE | SS_GRAYRECT,
|
||||
10, 70, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 4 - gray frame.
|
||||
DPRINT("test 4");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE | SS_GRAYFRAME,
|
||||
10, 100, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 5 - left-aligned text.
|
||||
DPRINT("test 5");
|
||||
CreateWindowEx(0, STATIC_CLASS,
|
||||
"&Left-aligned text &static control window",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
10, 130, 100, 50, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 6 - right-aligned text.
|
||||
DPRINT("test 6");
|
||||
CreateWindowEx(0, STATIC_CLASS,
|
||||
"&Right-aligned text &static control window",
|
||||
WS_CHILD | WS_VISIBLE | SS_RIGHT,
|
||||
10, 185, 100, 50, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 7 - centered text.
|
||||
DPRINT("test 7");
|
||||
CreateWindowEx(0, STATIC_CLASS,
|
||||
"&Centered text &static control window",
|
||||
WS_CHILD | WS_VISIBLE | SS_CENTER,
|
||||
10, 240, 100, 50, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 8 - left-aligned text with no word wrap and no prefixes.
|
||||
DPRINT("test 8");
|
||||
CreateWindowEx(0, STATIC_CLASS,
|
||||
"&No prefix and no word wrapping",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFTNOWORDWRAP | SS_NOPREFIX,
|
||||
10, 295, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 9 - white rectangle.
|
||||
DPRINT("test 9");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE | SS_WHITERECT,
|
||||
120, 10, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 10 - white frame.
|
||||
DPRINT("test 10");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE | SS_WHITEFRAME,
|
||||
120, 40, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 11 - etched frame.
|
||||
DPRINT("test 11");
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE
|
||||
| SS_ETCHEDFRAME, 120, 70, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
// Test 12 - etched horizontal lines.
|
||||
DPRINT("test 12");
|
||||
for (i = 0; i < 5; ++i)
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE
|
||||
| SS_ETCHEDHORZ, 120, 100 + (4L * i), 100, 4, Wnd,
|
||||
NULL, AppInstance, NULL);
|
||||
// Test 13 - etched vertical lines.
|
||||
DPRINT("test 13");
|
||||
for (i = 0; i < 25; ++i)
|
||||
CreateWindowEx(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE
|
||||
| SS_ETCHEDVERT, 120 + (4L * i), 130, 4, 20, Wnd,
|
||||
NULL, AppInstance, NULL);
|
||||
// Test 14 - sunken border.
|
||||
DPRINT("test 14");
|
||||
CreateWindowEx(0, STATIC_CLASS,
|
||||
"Sunken frame and word ellipsis",
|
||||
WS_CHILD | WS_VISIBLE | SS_SUNKEN | SS_WORDELLIPSIS,
|
||||
120, 160, 100, 20, Wnd, NULL, AppInstance, NULL);
|
||||
DPRINT("WM_CREATE (leave).");
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK TestWndProc(
|
||||
HWND Wnd,
|
||||
UINT Msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
switch (Msg) {
|
||||
case WM_CREATE:
|
||||
return WmCreate(Wnd);
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
default:
|
||||
return DefWindowProc(Wnd, Msg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
int STDCALL WinMain(
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nShowCmd)
|
||||
{
|
||||
ATOM Result;
|
||||
MSG Msg;
|
||||
HWND MainWindow;
|
||||
WNDCLASSEX TestWndClass = {0};
|
||||
DPRINT("Application starting up.");
|
||||
// Remember instance handle.
|
||||
AppInstance = GetModuleHandle(NULL);
|
||||
// Register test window class.
|
||||
TestWndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
TestWndClass.lpfnWndProc = &TestWndProc;
|
||||
TestWndClass.hInstance = AppInstance;
|
||||
TestWndClass.hCursor = LoadCursor(0, (LPCTSTR)IDC_ARROW);
|
||||
TestWndClass.hbrBackground = CreateSolidBrush(RGB(255,255,230));
|
||||
TestWndClass.lpszClassName = TEST_WND_CLASS;
|
||||
Result = RegisterClassEx(&TestWndClass);
|
||||
if (Result == 0) {
|
||||
DPRINT("Error registering class.");
|
||||
MessageBox(0, "Error registering test window class.",
|
||||
"Static control test", MB_ICONSTOP | MB_OK);
|
||||
ExitProcess(0);
|
||||
}
|
||||
// Create main window.
|
||||
DPRINT("Creating main window.");
|
||||
MainWindow = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_CLIENTEDGE,
|
||||
TEST_WND_CLASS, "Static control test",
|
||||
WS_OVERLAPPEDWINDOW, 50, 50, 245, 365,
|
||||
NULL, NULL, AppInstance, NULL);
|
||||
if (MainWindow == 0) {
|
||||
DPRINT("Error creating main window.");
|
||||
UnregisterClass(TEST_WND_CLASS, AppInstance);
|
||||
MessageBox(0, "Error creating test window.",
|
||||
"Static control test", MB_ICONSTOP | MB_OK);
|
||||
ExitProcess(0);
|
||||
}
|
||||
DPRINT("Showing main window.");
|
||||
ShowWindow(MainWindow, SW_SHOWNORMAL);
|
||||
UpdateWindow(MainWindow);
|
||||
// Run message loop.
|
||||
DPRINT("Entering message loop.");
|
||||
while (GetMessage(&Msg, NULL, 0, 0) > 0) {
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
}
|
||||
// Unregister window class.
|
||||
UnregisterClass(TEST_WND_CLASS, AppInstance);
|
||||
DPRINT("Exiting.");
|
||||
|
||||
return Msg.wParam;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
Binary file not shown.
Before Width: | Height: | Size: 87 KiB |
|
@ -1,31 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = stretchblt
|
||||
|
||||
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 = \
|
||||
stretchblt.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,380 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 1 - Listing 1.5 (StretchBlt Zooming 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.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// Modified by Aleksey Bragin (aleksey at studiocerebral.com)
|
||||
// to support non-uniform scaling, and output via sretchdibits
|
||||
// (type something in the command line to invoke this mode,
|
||||
// in future it will be source BPP)
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
HWND HListBox = NULL;
|
||||
HWND VListBox = NULL;
|
||||
const int ID_LISTBOX = 101;
|
||||
const int ID_LISTBOX2 = 102;
|
||||
BOOL useDIBits=FALSE; // How to display the image - via StretchDIBits
|
||||
|
||||
HINSTANCE HInst;
|
||||
HINSTANCE HPrevInst;
|
||||
TCHAR *cmdline;
|
||||
const char* WndClassName = "GMainWnd";
|
||||
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
|
||||
LPARAM LParam);
|
||||
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance,
|
||||
LPTSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
HInst = HInstance;
|
||||
HPrevInst = HPrevInstance;
|
||||
cmdline = lpCmdLine;
|
||||
|
||||
WNDCLASS wc;
|
||||
memset(&wc, 0, sizeof(WNDCLASS));
|
||||
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.hInstance = HInstance;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1);
|
||||
wc.lpszClassName = WndClassName;
|
||||
|
||||
if (RegisterClass(&wc))
|
||||
{
|
||||
HWND HWnd =
|
||||
CreateWindow(WndClassName, TEXT("StretchBlt NonUniform Zooming Demo"),
|
||||
WS_OVERLAPPEDWINDOW | WS_CAPTION |
|
||||
WS_VISIBLE | WS_CLIPSIBLINGS,
|
||||
0, 0, 675, 560,
|
||||
NULL, NULL, HInst, NULL);
|
||||
|
||||
if (HWnd)
|
||||
{
|
||||
HListBox =
|
||||
CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "",
|
||||
LBS_NOTIFY | WS_CHILD | WS_VISIBLE,
|
||||
530, 5, 130, 150, HWnd,
|
||||
reinterpret_cast<HMENU>(ID_LISTBOX),
|
||||
HInst, NULL);
|
||||
VListBox =
|
||||
CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "",
|
||||
LBS_NOTIFY | WS_CHILD | WS_VISIBLE,
|
||||
530, 5+170, 130, 150, HWnd,
|
||||
reinterpret_cast<HMENU>(ID_LISTBOX2),
|
||||
HInst, NULL);
|
||||
|
||||
if (HListBox && VListBox)
|
||||
{
|
||||
// horizontal zoom
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 25%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 50%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 75%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 100%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 125%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 150%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 200%"));
|
||||
SNDMSG(HListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 300%"));
|
||||
// vertical zoom
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 25%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 50%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 75%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 100%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 125%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 150%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 200%"));
|
||||
SNDMSG(VListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>("Zoom 300%"));
|
||||
|
||||
}
|
||||
|
||||
ShowWindow(HWnd, nCmdShow);
|
||||
UpdateWindow(HWnd);
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// image related
|
||||
BITMAP bmp;
|
||||
BITMAPINFO bmInfo;
|
||||
char *bbits = NULL; // bitmap bits
|
||||
const char* filename = "LENA.BMP";
|
||||
HDC HMemDC = NULL;
|
||||
HBITMAP HOldBmp = NULL;
|
||||
|
||||
// zooming related
|
||||
float zoom_factor_h = 0.5;
|
||||
float zoom_factor_v = 0.5;
|
||||
RECT RDest = {5, 5, 0, 0};
|
||||
enum {ID_ZOOM25, ID_ZOOM50, ID_ZOOM75, ID_ZOOM100,
|
||||
ID_ZOOM125, ID_ZOOM150, ID_ZOOM200, ID_ZOOM300};
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
|
||||
LPARAM LParam)
|
||||
{
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
// check commandline
|
||||
if (strlen(cmdline) != 0)
|
||||
{
|
||||
|
||||
useDIBits = TRUE;
|
||||
}
|
||||
else
|
||||
useDIBits = FALSE;
|
||||
|
||||
// create a memory DC
|
||||
HMemDC = CreateCompatibleDC(NULL);
|
||||
if (HMemDC)
|
||||
{
|
||||
// load a bitmap from file
|
||||
HBITMAP HBmp =
|
||||
static_cast<HBITMAP>(
|
||||
LoadImage(HInst, filename, IMAGE_BITMAP,
|
||||
0, 0, LR_LOADFROMFILE)
|
||||
);
|
||||
if (HBmp)
|
||||
{
|
||||
// extract dimensions of the bitmap
|
||||
GetObject(HBmp, sizeof(BITMAP), &bmp);
|
||||
|
||||
// fill the BITMAPINFO stucture for further use by StretchDIBits
|
||||
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmInfo.bmiHeader.biWidth = bmp.bmWidth;
|
||||
bmInfo.bmiHeader.biHeight = bmp.bmHeight;
|
||||
bmInfo.bmiHeader.biPlanes = 1;//bmp.bmPlanes;
|
||||
bmInfo.bmiHeader.biBitCount = bmp.bmBitsPixel;
|
||||
bmInfo.bmiHeader.biCompression = BI_RGB;
|
||||
bmInfo.bmiHeader.biSizeImage = 0;
|
||||
bmInfo.bmiHeader.biXPelsPerMeter = 0;
|
||||
bmInfo.bmiHeader.biClrImportant = 0;
|
||||
bmInfo.bmiHeader.biClrUsed = 0;
|
||||
|
||||
// associate the bitmap with the memory DC
|
||||
HOldBmp = static_cast<HBITMAP>(
|
||||
SelectObject(HMemDC, HBmp)
|
||||
);
|
||||
|
||||
if (useDIBits)
|
||||
{
|
||||
bbits = new char[bmp.bmHeight*bmp.bmWidthBytes*(bmp.bmBitsPixel / 8)];
|
||||
//GetDIBits(HMemDC, HBmp, 0, bmp.bmHeight, bbits, &bmInfo, DIB_RGB_COLORS);
|
||||
|
||||
// Here goes a temp hack, since GetDIBits doesn't exist in ReactOS yet
|
||||
FILE *f = fopen(filename, "rb");
|
||||
BITMAPFILEHEADER bmpHeader;
|
||||
|
||||
fread(&bmpHeader, sizeof(BITMAPFILEHEADER), 1, f);
|
||||
fread(&bmInfo, sizeof(BITMAPINFO), 1, f);
|
||||
fseek(f, bmpHeader.bfOffBits, SEEK_SET);
|
||||
fread(bbits, bmp.bmHeight*bmp.bmWidthBytes*(bmp.bmBitsPixel / 8), 1, f);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if (WParam == MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) ||
|
||||
WParam == MAKEWPARAM(ID_LISTBOX2, LBN_SELCHANGE))
|
||||
{
|
||||
switch (SNDMSG(HListBox, LB_GETCURSEL, 0, 0))
|
||||
{
|
||||
case ID_ZOOM25: zoom_factor_h = 0.25; break;
|
||||
case ID_ZOOM50: zoom_factor_h = 0.50; break;
|
||||
case ID_ZOOM75: zoom_factor_h = 0.75; break;
|
||||
case ID_ZOOM100: zoom_factor_h = 1.00; break;
|
||||
case ID_ZOOM125: zoom_factor_h = 1.25; break;
|
||||
case ID_ZOOM150: zoom_factor_h = 1.50; break;
|
||||
case ID_ZOOM200: zoom_factor_h = 2.00; break;
|
||||
case ID_ZOOM300: zoom_factor_h = 3.00; break;
|
||||
}
|
||||
|
||||
switch (SNDMSG(VListBox, LB_GETCURSEL, 0, 0))
|
||||
{
|
||||
case ID_ZOOM25: zoom_factor_v = 0.25; break;
|
||||
case ID_ZOOM50: zoom_factor_v = 0.50; break;
|
||||
case ID_ZOOM75: zoom_factor_v = 0.75; break;
|
||||
case ID_ZOOM100: zoom_factor_v = 1.00; break;
|
||||
case ID_ZOOM125: zoom_factor_v = 1.25; break;
|
||||
case ID_ZOOM150: zoom_factor_v = 1.50; break;
|
||||
case ID_ZOOM200: zoom_factor_v = 2.00; break;
|
||||
case ID_ZOOM300: zoom_factor_v = 3.00; break;
|
||||
}
|
||||
|
||||
// calculate the new width and height
|
||||
const int new_width =
|
||||
static_cast<int>(zoom_factor_h * bmp.bmWidth);
|
||||
const int new_height =
|
||||
static_cast<int>(zoom_factor_v * bmp.bmHeight);
|
||||
|
||||
// is zooming in?
|
||||
bool zoom_in = (new_width > RDest.right - RDest.left);
|
||||
|
||||
// caculate the area that needs to be updated
|
||||
RECT RUpdate = {
|
||||
RDest.left, RDest.top,
|
||||
RDest.left + max(new_width, RDest.right - RDest.left),
|
||||
RDest.top + max(new_height, RDest.bottom - RDest.top)
|
||||
};
|
||||
|
||||
// adjust the dimenstions of the
|
||||
// destination rectangle
|
||||
RDest.right = RDest.left + new_width;
|
||||
RDest.bottom = RDest.top + new_height;
|
||||
|
||||
// create an update region from the XOR combination
|
||||
// of the update and destination rectangles
|
||||
HRGN HUpdateRgn = CreateRectRgnIndirect(&RUpdate);
|
||||
HRGN HDestRgn = CreateRectRgnIndirect(&RDest);
|
||||
int result =
|
||||
CombineRgn(HUpdateRgn, HUpdateRgn, HDestRgn, RGN_XOR);
|
||||
|
||||
// incite a repaint
|
||||
if (result != NULLREGION && result != ERROR)
|
||||
{
|
||||
InvalidateRgn(HWnd, HUpdateRgn, true);
|
||||
RedrawWindow(HWnd, &RDest, NULL, RDW_NOERASE | RDW_INVALIDATE);
|
||||
}
|
||||
else if (result == NULLREGION)
|
||||
{
|
||||
InvalidateRect(HWnd, &RUpdate, zoom_in ? false : true);
|
||||
}
|
||||
|
||||
// clean up
|
||||
DeleteObject(HUpdateRgn);
|
||||
DeleteObject(HDestRgn);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
const HDC Hdc = BeginPaint(HWnd, &ps);
|
||||
#if 0
|
||||
try
|
||||
#endif
|
||||
{
|
||||
//
|
||||
// TODO: add palette support (see Chapter 9)...
|
||||
//
|
||||
if (useDIBits)
|
||||
{
|
||||
if (RDest.right - RDest.left > 0)
|
||||
{
|
||||
if (zoom_factor_h < 1.0 || zoom_factor_v < 1.0)
|
||||
{
|
||||
SetStretchBltMode(Hdc, COLORONCOLOR);
|
||||
}
|
||||
|
||||
// render the zoomed image
|
||||
StretchDIBits(Hdc, RDest.left, RDest.top,
|
||||
RDest.right - RDest.left,
|
||||
RDest.bottom - RDest.top,
|
||||
0, 0,
|
||||
bmp.bmWidth, bmp.bmHeight,
|
||||
bbits, &bmInfo,
|
||||
DIB_RGB_COLORS,
|
||||
SRCCOPY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RDest.right - RDest.left > 0)
|
||||
{
|
||||
|
||||
// use BitBlt when not zooming
|
||||
if (zoom_factor_h == 1.0 && zoom_factor_v == 1.0)
|
||||
{
|
||||
BitBlt(Hdc, RDest.left, RDest.top,
|
||||
RDest.right - RDest.left,
|
||||
RDest.bottom - RDest.top,
|
||||
HMemDC, 0, 0,
|
||||
SRCCOPY);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zoom_factor_h < 1.0 || zoom_factor_v < 1.0)
|
||||
{
|
||||
SetStretchBltMode(Hdc, COLORONCOLOR);
|
||||
}
|
||||
|
||||
// render the zoomed image
|
||||
StretchBlt(Hdc, RDest.left, RDest.top,
|
||||
RDest.right - RDest.left,
|
||||
RDest.bottom - RDest.top,
|
||||
HMemDC, 0, 0,
|
||||
bmp.bmWidth, bmp.bmHeight,
|
||||
SRCCOPY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
catch (...)
|
||||
#endif
|
||||
{
|
||||
EndPaint(HWnd, &ps);
|
||||
}
|
||||
EndPaint(HWnd, &ps);
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
// clean up
|
||||
DeleteObject(SelectObject(HMemDC, HOldBmp));
|
||||
DeleteDC(HMemDC);
|
||||
|
||||
if (bbits)
|
||||
delete bbits;
|
||||
|
||||
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.2 2003/11/14 17:13:20 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = subclass
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a gdi32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS -Werror -Wall
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,173 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
LRESULT WINAPI UnicodeWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT WINAPI UnicodeSubclassProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT WINAPI AnsiSubclassProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
static WNDPROC SavedWndProcW;
|
||||
static WNDPROC SavedWndProcA;
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
WNDCLASSW wc;
|
||||
MSG msg;
|
||||
HWND hWnd;
|
||||
WCHAR WindowTextW[256];
|
||||
char WindowTextA[256];
|
||||
|
||||
wc.lpszClassName = L"UnicodeClass";
|
||||
wc.lpfnWndProc = UnicodeWndProc;
|
||||
wc.style = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = NULL;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
if (RegisterClassW(&wc) == 0)
|
||||
{
|
||||
fprintf(stderr, "RegisterClassW failed (last error 0x%X)\n",
|
||||
GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("Unicode class registered, WndProc = 0x%08x\n", wc.lpfnWndProc);
|
||||
|
||||
hWnd = CreateWindowA("UnicodeClass",
|
||||
"Unicode Window",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0,
|
||||
0,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
fprintf(stderr, "CreateWindowA failed (last error 0x%X)\n",
|
||||
GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Window created, IsWindowUnicode returns %s\n", IsWindowUnicode(hWnd) ? "TRUE" : "FALSE");
|
||||
|
||||
printf("Calling GetWindowTextW\n");
|
||||
if (! GetWindowTextW(hWnd, WindowTextW, sizeof(WindowTextW) / sizeof(WindowTextW[0])))
|
||||
{
|
||||
fprintf(stderr, "GetWindowTextW failed (last error 0x%X)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("GetWindowTextW returned Unicode string \"%S\"\n", WindowTextW);
|
||||
|
||||
printf("Calling GetWindowTextA\n");
|
||||
if (! GetWindowTextA(hWnd, WindowTextA, sizeof(WindowTextA) / sizeof(WindowTextA[0])))
|
||||
{
|
||||
fprintf(stderr, "GetWindowTextA failed (last error 0x%X)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("GetWindowTextA returned Ansi string \"%s\"\n", WindowTextA);
|
||||
printf("\n");
|
||||
|
||||
SavedWndProcW = (WNDPROC) GetWindowLongW(hWnd, GWL_WNDPROC);
|
||||
printf("GetWindowLongW returned 0x%08x\n", SavedWndProcW);
|
||||
SavedWndProcA = (WNDPROC) GetWindowLongA(hWnd, GWL_WNDPROC);
|
||||
printf("GetWindowLongA returned 0x%08x\n", SavedWndProcA);
|
||||
printf("\n");
|
||||
|
||||
printf("Subclassing window using SetWindowLongW, new WndProc 0x%08x\n", UnicodeSubclassProc);
|
||||
SetWindowLongW(hWnd, GWL_WNDPROC, (LONG) UnicodeSubclassProc);
|
||||
printf("After subclass, IsWindowUnicode %s, WndProcA 0x%08x, WndProcW 0x%08x\n",
|
||||
IsWindowUnicode(hWnd) ? "TRUE" : "FALSE", GetWindowLongA(hWnd, GWL_WNDPROC),
|
||||
GetWindowLongW(hWnd, GWL_WNDPROC));
|
||||
|
||||
printf("Calling GetWindowTextW\n");
|
||||
if (! GetWindowTextW(hWnd, WindowTextW, sizeof(WindowTextW) / sizeof(WindowTextW[0])))
|
||||
{
|
||||
fprintf(stderr, "GetWindowTextW failed (last error 0x%X)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("GetWindowTextW returned Unicode string \"%S\"\n", WindowTextW);
|
||||
printf("\n");
|
||||
|
||||
printf("Subclassing window using SetWindowLongA, new WndProc 0x%08x\n", AnsiSubclassProc);
|
||||
SetWindowLongA(hWnd, GWL_WNDPROC, (LONG) AnsiSubclassProc);
|
||||
printf("After subclass, IsWindowUnicode %s, WndProcA 0x%08x, WndProcW 0x%08x\n",
|
||||
IsWindowUnicode(hWnd) ? "TRUE" : "FALSE", GetWindowLongA(hWnd, GWL_WNDPROC),
|
||||
GetWindowLongW(hWnd, GWL_WNDPROC));
|
||||
|
||||
printf("Calling GetWindowTextW\n");
|
||||
if (! GetWindowTextW(hWnd, WindowTextW, sizeof(WindowTextW) / sizeof(WindowTextW[0])))
|
||||
{
|
||||
fprintf(stderr, "GetWindowTextW failed (last error 0x%X)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("GetWindowTextW returned Unicode string \"%S\"\n", WindowTextW);
|
||||
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK UnicodeWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT Result;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_GETTEXT:
|
||||
printf("UnicodeWndProc calling DefWindowProcW\n");
|
||||
Result = DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||
printf("UnicodeWndProc Unicode window text \"%S\"\n", (LPWSTR) lParam);
|
||||
break;
|
||||
default:
|
||||
Result = DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK UnicodeSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT Result;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_GETTEXT:
|
||||
printf("UnicodeSubclassProc calling SavedWindowProc\n");
|
||||
Result = CallWindowProcW(SavedWndProcW, hWnd, msg, wParam, lParam);
|
||||
printf("UnicodeSubclassProc Unicode window text \"%S\"\n", (LPWSTR) lParam);
|
||||
break;
|
||||
default:
|
||||
Result = CallWindowProcW(SavedWndProcW, hWnd, msg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK AnsiSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT Result;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_GETTEXT:
|
||||
printf("AnsiSubclassProc calling SavedWindowProcA\n");
|
||||
Result = CallWindowProcA(SavedWndProcA, hWnd, msg, wParam, lParam);
|
||||
printf("AnsiSubclassProc Ansi window text \"%s\"\n", (LPSTR) lParam);
|
||||
break;
|
||||
default:
|
||||
Result = CallWindowProcA(SavedWndProcA, hWnd, msg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue