- Tree cleanups proposed on the mailing list. Move all non-Core OS modules to rosapps. Tests were already moved by Fireball to rostests.
svn path=/trunk/; revision=26033
8
rosapps/avtest/avtest.rbuild
Executable file
|
@ -0,0 +1,8 @@
|
|||
<module name="avtest" type="kernelmodedriver" installbase="system32/drivers" installname="avtest.sys" warnings="true">
|
||||
<include base="avtest">.</include>
|
||||
<include base="avtest">..</include>
|
||||
<define name="__USE_W32API" />
|
||||
<library>ks</library>
|
||||
<library>ntoskrnl</library>
|
||||
<file>entry.c</file>
|
||||
</module>
|
83
rosapps/avtest/entry.c
Executable file
|
@ -0,0 +1,83 @@
|
|||
#include <debug.h>
|
||||
#include <ks.h>
|
||||
|
||||
/* Where do we go? */
|
||||
#ifndef SIZEOF_ARRAY
|
||||
#define SIZEOF_ARRAY(array) \
|
||||
(sizeof(array) / sizeof(array[0]))
|
||||
#endif
|
||||
|
||||
/* Not in the DDK but hey! */
|
||||
#define DEFINE_KSFILTER_DISPATCH(name) \
|
||||
const KSFILTER_DISPATCH name =
|
||||
|
||||
/* To be put in KS.H */
|
||||
#define DEFINE_KSFILTER_DESCRIPTOR(name) \
|
||||
const KSFILTER_DESCRIPTOR name =
|
||||
|
||||
#define DEFINE_KSFILTER_DESCRIPTOR_TABLE(name) \
|
||||
const KSFILTER_DESCRIPTOR* const name[] =
|
||||
|
||||
|
||||
|
||||
NTSTATUS FilterCreate(
|
||||
IN OUT PKSFILTER Filter,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FilterClose(
|
||||
IN OUT PKSFILTER Filter,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS Process(
|
||||
IN PKSFILTER Filter,
|
||||
IN PKSPROCESSPIN_INDEXENTRY ProcessPinsIndex)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DEFINE_KSFILTER_DISPATCH(FilterDispatch)
|
||||
{
|
||||
FilterCreate,
|
||||
FilterClose,
|
||||
Process,
|
||||
NULL // Reset
|
||||
};
|
||||
|
||||
DEFINE_KSFILTER_DESCRIPTOR(FilterDesc)
|
||||
{
|
||||
};
|
||||
|
||||
DEFINE_KSFILTER_DESCRIPTOR_TABLE(FilterDescs)
|
||||
{
|
||||
&FilterDesc
|
||||
};
|
||||
|
||||
|
||||
|
||||
const KSDEVICE_DESCRIPTOR DeviceDescriptor =
|
||||
{
|
||||
NULL,
|
||||
SIZEOF_ARRAY(FilterDescs),
|
||||
FilterDescs
|
||||
};
|
||||
|
||||
|
||||
/* Funcs */
|
||||
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPathName)
|
||||
{
|
||||
DPRINT1("AVStream test component loaded!\n");
|
||||
|
||||
return KsInitializeDriver(DriverObject, RegistryPathName,
|
||||
&DeviceDescriptor);
|
||||
}
|
303
rosapps/downloader/download.c
Normal file
|
@ -0,0 +1,303 @@
|
|||
/* PROJECT: ReactOS Downloader (was GetFirefox)
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/applications/downloader/download.c
|
||||
* PURPOSE: Displaying a download dialog
|
||||
* COPYRIGHT: Copyright 2001 John R. Sheets (for CodeWeavers)
|
||||
* Copyright 2004 Mike McCormack (for CodeWeavers)
|
||||
* Copyright 2005 Ge van Geldorp (gvg@reactos.org)
|
||||
*/
|
||||
/*
|
||||
* Based on Wine dlls/shdocvw/shdocvw_main.c
|
||||
*
|
||||
* 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 COBJMACROS
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <urlmon.h>
|
||||
|
||||
#include "resources.h"
|
||||
#include "structures.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
extern struct Application* SelectedApplication;
|
||||
extern WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
|
||||
|
||||
typedef struct _IBindStatusCallbackImpl
|
||||
{
|
||||
const IBindStatusCallbackVtbl *vtbl;
|
||||
LONG ref;
|
||||
HWND hDialog;
|
||||
BOOL *pbCancelled;
|
||||
} IBindStatusCallbackImpl;
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlQueryInterface(IBindStatusCallback* This, REFIID riid, void** ppvObject)
|
||||
{
|
||||
if (NULL == ppvObject)
|
||||
{
|
||||
return E_POINTER;
|
||||
}
|
||||
|
||||
if (IsEqualIID(riid, &IID_IUnknown) ||
|
||||
IsEqualIID(riid, &IID_IBindStatusCallback))
|
||||
{
|
||||
IBindStatusCallback_AddRef( This );
|
||||
*ppvObject = This;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI
|
||||
dlAddRef(IBindStatusCallback* iface)
|
||||
{
|
||||
IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface;
|
||||
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static ULONG WINAPI
|
||||
dlRelease(IBindStatusCallback* iface)
|
||||
{
|
||||
IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface;
|
||||
DWORD ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
if( !ref )
|
||||
{
|
||||
DestroyWindow( This->hDialog );
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlOnStartBinding(IBindStatusCallback* iface, DWORD dwReserved, IBinding* pib)
|
||||
{
|
||||
DPRINT1("OnStartBinding not implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlGetPriority(IBindStatusCallback* iface, LONG* pnPriority)
|
||||
{
|
||||
DPRINT1("GetPriority not implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlOnLowResource( IBindStatusCallback* iface, DWORD reserved)
|
||||
{
|
||||
DPRINT1("OnLowResource not implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlOnProgress(IBindStatusCallback* iface, ULONG ulProgress,
|
||||
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
|
||||
{
|
||||
IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface;
|
||||
HWND Item;
|
||||
LONG r;
|
||||
WCHAR OldText[100];
|
||||
|
||||
Item = GetDlgItem(This->hDialog, IDC_PROGRESS);
|
||||
if (NULL != Item && 0 != ulProgressMax)
|
||||
{
|
||||
SendMessageW(Item, PBM_SETPOS, (ulProgress * 100) / ulProgressMax, 0);
|
||||
}
|
||||
|
||||
Item = GetDlgItem(This->hDialog, IDC_STATUS);
|
||||
if (NULL != Item && NULL != szStatusText)
|
||||
{
|
||||
SendMessageW(Item, WM_GETTEXT, sizeof(OldText) / sizeof(OldText[0]),
|
||||
(LPARAM) OldText);
|
||||
if (sizeof(OldText) / sizeof(OldText[0]) - 1 <= wcslen(OldText) ||
|
||||
0 != wcscmp(OldText, szStatusText))
|
||||
{
|
||||
SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) szStatusText);
|
||||
}
|
||||
}
|
||||
|
||||
SetLastError(0);
|
||||
r = GetWindowLongPtrW(This->hDialog, GWLP_USERDATA);
|
||||
if (0 != r || 0 != GetLastError())
|
||||
{
|
||||
*This->pbCancelled = TRUE;
|
||||
DPRINT("Cancelled\n");
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlOnStopBinding(IBindStatusCallback* iface, HRESULT hresult, LPCWSTR szError)
|
||||
{
|
||||
DPRINT1("OnStopBinding not implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlGetBindInfo(IBindStatusCallback* iface, DWORD* grfBINDF, BINDINFO* pbindinfo)
|
||||
{
|
||||
DPRINT1("GetBindInfo not implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlOnDataAvailable(IBindStatusCallback* iface, DWORD grfBSCF,
|
||||
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
||||
{
|
||||
DPRINT1("OnDataAvailable implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
dlOnObjectAvailable(IBindStatusCallback* iface, REFIID riid, IUnknown* punk)
|
||||
{
|
||||
DPRINT1("OnObjectAvailable implemented\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IBindStatusCallbackVtbl dlVtbl =
|
||||
{
|
||||
dlQueryInterface,
|
||||
dlAddRef,
|
||||
dlRelease,
|
||||
dlOnStartBinding,
|
||||
dlGetPriority,
|
||||
dlOnLowResource,
|
||||
dlOnProgress,
|
||||
dlOnStopBinding,
|
||||
dlGetBindInfo,
|
||||
dlOnDataAvailable,
|
||||
dlOnObjectAvailable
|
||||
};
|
||||
|
||||
static IBindStatusCallback*
|
||||
CreateDl(HWND Dlg, BOOL *pbCancelled)
|
||||
{
|
||||
IBindStatusCallbackImpl *This;
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(IBindStatusCallbackImpl));
|
||||
This->vtbl = &dlVtbl;
|
||||
This->ref = 1;
|
||||
This->hDialog = Dlg;
|
||||
This->pbCancelled = pbCancelled;
|
||||
|
||||
return (IBindStatusCallback*) This;
|
||||
}
|
||||
|
||||
static DWORD WINAPI
|
||||
ThreadFunc(LPVOID Context)
|
||||
{
|
||||
//static const WCHAR szUrl[] = DownloadUrl;
|
||||
IBindStatusCallback *dl;
|
||||
HWND Dlg = ((struct lParamDownload*)Context)->Dlg;
|
||||
DWORD r;
|
||||
BOOL bCancelled = FALSE;
|
||||
dl = CreateDl(Dlg, &bCancelled);
|
||||
r = URLDownloadToFileW(NULL, ((struct lParamDownload*)Context)->URL, ((struct lParamDownload*)Context)->File, 0, dl);
|
||||
if (NULL != dl)
|
||||
{
|
||||
IBindStatusCallback_Release(dl);
|
||||
}
|
||||
if (S_OK != r)
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_DOWNLOAD_ERROR],0,0);
|
||||
}
|
||||
EndDialog(Dlg, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK
|
||||
DownloadProc(HWND Dlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HANDLE Thread;
|
||||
DWORD ThreadId;
|
||||
HWND Item;;
|
||||
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_INITDIALOG:/*
|
||||
Icon = LoadIconW((HINSTANCE) GetWindowLongPtr(Dlg, GWLP_HINSTANCE),
|
||||
MAKEINTRESOURCEW(IDI_ICON_MAIN));
|
||||
if (NULL != Icon)
|
||||
{
|
||||
SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM) Icon);
|
||||
SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM) Icon);
|
||||
}*/
|
||||
SetWindowLongPtrW(Dlg, GWLP_USERDATA, 0);
|
||||
Item = GetDlgItem(Dlg, IDC_PROGRESS);
|
||||
if (NULL != Item)
|
||||
{
|
||||
SendMessageW(Item, PBM_SETRANGE, 0, MAKELPARAM(0,100));
|
||||
SendMessageW(Item, PBM_SETPOS, 0, 0);
|
||||
}/*
|
||||
Item = GetDlgItem(Dlg, IDC_REMOVE);
|
||||
if (NULL != Item)
|
||||
{
|
||||
if (GetShortcutName(ShortcutName) &&
|
||||
INVALID_FILE_ATTRIBUTES != GetFileAttributesW(ShortcutName))
|
||||
{
|
||||
SendMessageW(Item, BM_SETCHECK, BST_CHECKED, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageW(Item, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
ShowWindow(Item, SW_HIDE);
|
||||
}
|
||||
}*/
|
||||
((struct lParamDownload*)lParam)->Dlg = Dlg;
|
||||
Thread = CreateThread(NULL, 0, ThreadFunc, (LPVOID)lParam, 0, &ThreadId);
|
||||
if (NULL == Thread)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
CloseHandle(Thread);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (wParam == IDCANCEL)
|
||||
{
|
||||
SetWindowLongPtrW(Dlg, GWLP_USERDATA, 1);
|
||||
PostMessage(Dlg, WM_CLOSE, 0, 0);
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_CLOSE:
|
||||
EndDialog(Dlg, 0);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
34
rosapps/downloader/downloader.rbuild
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<directory name="packagetree">
|
||||
<xi:include href="packagetree/packagetree.rbuild" />
|
||||
</directory>
|
||||
<module name="downloader" type="win32gui" installbase="system32" installname="downloader.exe">
|
||||
<include base="downloader">.</include>
|
||||
<include base="expat">.</include>
|
||||
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="__USE_W32API" />
|
||||
<define name="WINVER">0x0501</define>
|
||||
<define name="_WIN32_IE>0x0600</define>
|
||||
|
||||
<library>kernel32</library>
|
||||
<library>advapi32</library>
|
||||
<library>ntdll</library>
|
||||
<library>user32</library>
|
||||
<library>gdi32</library>
|
||||
<library>shell32</library>
|
||||
<library>comctl32</library>
|
||||
<library>msimg32</library>
|
||||
<library>shlwapi</library>
|
||||
<library>urlmon</library>
|
||||
<library>uuid</library>
|
||||
<library>expat</library>
|
||||
|
||||
<file>main.c</file>
|
||||
<file>xml.c</file>
|
||||
<file>download.c</file>
|
||||
<file>script.c</file>
|
||||
<file>downloader.rc</file>
|
||||
</module>
|
10
rosapps/downloader/downloader.rc
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <windows.h>
|
||||
#include "resources.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Download !\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "downloader\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "downloader.exe\0"
|
||||
|
||||
#include <reactos/version.rc>
|
||||
|
||||
#include "rsrc.rc"
|
538
rosapps/downloader/main.c
Normal file
|
@ -0,0 +1,538 @@
|
|||
/* PROJECT: ReactOS Downloader
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/applications/downloader/xml.c
|
||||
* PURPOSE: Main program
|
||||
* PROGRAMMERS: Maarten Bosma, Lester Kortenhoeven
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#include <stdio.h>
|
||||
#include <shlwapi.h>
|
||||
#include <wchar.h>
|
||||
#include "resources.h"
|
||||
#include "structures.h"
|
||||
|
||||
#define XML_PATH "tree.xml"
|
||||
|
||||
HWND hwnd, hCategories, hApps, hDownloadButton, hUninstallButton, hUpdateButton, hHelpButton;
|
||||
HBITMAP hLogo, hUnderline;
|
||||
CHAR* CmdLine;
|
||||
WCHAR* DescriptionHeadline = L"";
|
||||
WCHAR* DescriptionText = L"";
|
||||
WCHAR ApplicationText[0xA04]; // MAX_STRING_LENGHT + Version + \n + MAX_STRING_LENGHT + Licence + \n + MAX_STRING_LENGHT + Maintainer + \n\n + Description
|
||||
// 0x100 + 0x100 + 1 + 0x100 + 0x100 + 1 + 0x100 + 0x100 + 2 + 0x400 = 0xA04
|
||||
struct Category Root;
|
||||
struct Application* SelectedApplication;
|
||||
|
||||
INT_PTR CALLBACK DownloadProc (HWND, UINT, WPARAM, LPARAM);
|
||||
DWORD WINAPI InstallThreadFunc(LPVOID);
|
||||
DWORD WINAPI UninstallThreadFunc(LPVOID);
|
||||
BOOL ProcessXML (const char* filename, struct Category* Root);
|
||||
char* addDML (const char*);
|
||||
VOID FreeTree (struct Category* Node);
|
||||
WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
|
||||
|
||||
BOOL getUninstaller(struct Application* CurrentApplication, WCHAR* Uninstaller) {
|
||||
|
||||
DWORD ArraySize = 0x100;
|
||||
|
||||
HKEY hKey1;
|
||||
HKEY hKey2;
|
||||
DWORD Type = 0;
|
||||
WCHAR Value[ArraySize];
|
||||
WCHAR KeyName[ArraySize];
|
||||
DWORD Size = ArraySize;
|
||||
LONG i = 0;
|
||||
|
||||
if (CurrentApplication->RegName[0] == L'\0') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_READ,&hKey1) == ERROR_SUCCESS) {
|
||||
if (RegOpenKeyExW(hKey1,CurrentApplication->RegName,0,KEY_READ,&hKey2) == ERROR_SUCCESS) {
|
||||
if (RegQueryValueExW(hKey2,L"UninstallString",0,&Type,(LPBYTE)Uninstaller,&Size) == ERROR_SUCCESS) {
|
||||
RegCloseKey(hKey2);
|
||||
RegCloseKey(hKey1);
|
||||
return TRUE;
|
||||
} else {
|
||||
RegCloseKey(hKey2);
|
||||
RegCloseKey(hKey1);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
while (RegEnumKeyExW(hKey1,i,KeyName,&Size,NULL,NULL,NULL,NULL) == ERROR_SUCCESS) {
|
||||
++i;
|
||||
RegOpenKeyExW(hKey1,KeyName,0,KEY_READ,&hKey2);
|
||||
Size = sizeof(Value);
|
||||
if (RegQueryValueExW(hKey2,L"DisplayName",0,&Type,(LPBYTE)Value,&Size) == ERROR_SUCCESS) {
|
||||
Size = ArraySize;
|
||||
if (!wcscmp(Value,CurrentApplication->RegName)) {
|
||||
if (RegQueryValueExW(hKey2,L"UninstallString",0,&Type,(LPBYTE)Uninstaller,&Size) == ERROR_SUCCESS) {
|
||||
RegCloseKey(hKey2);
|
||||
RegCloseKey(hKey1);
|
||||
return TRUE;
|
||||
} else {
|
||||
RegCloseKey(hKey2);
|
||||
RegCloseKey(hKey1);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
RegCloseKey(hKey2);
|
||||
Size = ArraySize;
|
||||
}
|
||||
RegCloseKey(hKey1);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ShowMessage (WCHAR* title, WCHAR* message)
|
||||
{
|
||||
DescriptionHeadline = title;
|
||||
DescriptionText = message;
|
||||
InvalidateRect(hwnd,NULL,TRUE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
|
||||
void AddItems (HWND hwnd, struct Category* Category, struct Category* Parent)
|
||||
{
|
||||
TV_INSERTSTRUCTW Insert;
|
||||
|
||||
Insert.item.lParam = (UINT)Category;
|
||||
Insert.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;;
|
||||
Insert.item.pszText = Category->Name;
|
||||
Insert.item.cchTextMax = lstrlenW(Category->Name);
|
||||
Insert.item.iImage = Category->Icon;
|
||||
Insert.item.iSelectedImage = Category->Icon;
|
||||
Insert.hInsertAfter = TVI_LAST;
|
||||
Insert.hParent = Category->Parent ? Category->Parent->TreeviewItem : TVI_ROOT;
|
||||
|
||||
Category->TreeviewItem = (HTREEITEM)SendMessage(hwnd, TVM_INSERTITEM, 0, (LPARAM)&Insert);
|
||||
|
||||
if(Category->Next)
|
||||
AddItems (hwnd,Category->Next,Parent);
|
||||
|
||||
if(Category->Children)
|
||||
AddItems (hwnd,Category->Children,Category);
|
||||
}
|
||||
|
||||
void CategoryChoosen (HWND hwnd, struct Category* Category)
|
||||
{
|
||||
struct Application* CurrentApplication;
|
||||
TV_INSERTSTRUCTW Insert;
|
||||
SelectedApplication = NULL;
|
||||
|
||||
if(Category->Children && !Category->Apps)
|
||||
ShowMessage(Category->Name, Strings[IDS_CHOOSE_SUB]);
|
||||
else if(!Category->Children && Category->Apps)
|
||||
ShowMessage(Category->Name, Strings[IDS_CHOOSE_APP]);
|
||||
else if(Category->Children && Category->Apps)
|
||||
ShowMessage(Category->Name, Strings[IDS_CHOOSE_BOTH]);
|
||||
else
|
||||
ShowMessage(Category->Name, Strings[IDS_NO_APPS]);
|
||||
|
||||
(void)TreeView_DeleteItem(hwnd, TVI_ROOT);
|
||||
(void)TreeView_DeleteItem(hwnd, TVI_ROOT); // Delete twice to bypass bug in windows
|
||||
|
||||
Insert.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE;
|
||||
Insert.hInsertAfter = TVI_LAST;
|
||||
Insert.hParent = TVI_ROOT;
|
||||
|
||||
CurrentApplication = Category->Apps;
|
||||
|
||||
while(CurrentApplication)
|
||||
{
|
||||
Insert.item.lParam = (UINT)CurrentApplication;
|
||||
Insert.item.pszText = CurrentApplication->Name;
|
||||
Insert.item.cchTextMax = lstrlenW(CurrentApplication->Name);
|
||||
if(getUninstaller(CurrentApplication, NULL)) {
|
||||
Insert.item.iImage = 9;
|
||||
} else {
|
||||
Insert.item.iImage = 10;
|
||||
}
|
||||
SendMessage(hwnd, TVM_INSERTITEM, 0, (LPARAM)&Insert);
|
||||
CurrentApplication = CurrentApplication->Next;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL SetupControls (HWND hwnd)
|
||||
{
|
||||
TV_INSERTSTRUCTW Insert = {0};
|
||||
HIMAGELIST hImageList;
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
|
||||
// Parse the XML file
|
||||
if (ProcessXML (XML_PATH, &Root) == FALSE)
|
||||
return FALSE;
|
||||
|
||||
// Set up the controls
|
||||
hCategories = CreateWindowExW(0, WC_TREEVIEWW, L"Categories", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
|
||||
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
|
||||
|
||||
hApps = CreateWindowExW(0, WC_TREEVIEWW, L"Applications", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
|
||||
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
|
||||
|
||||
hLogo = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LOGO));
|
||||
hUnderline = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_UNDERLINE));
|
||||
|
||||
hHelpButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 550, 10, 40, 40, hwnd, 0, hInstance, NULL);
|
||||
hUpdateButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 500, 10, 40, 40, hwnd, 0, hInstance, NULL);
|
||||
hDownloadButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 330, 505, 140, 35, hwnd, 0, hInstance, NULL);
|
||||
hUninstallButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 260, 505, 140, 35, hwnd, 0, hInstance, NULL);
|
||||
|
||||
SendMessageW(hHelpButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_HELP)));
|
||||
SendMessageW(hUpdateButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UPDATE)));
|
||||
SendMessageW(hDownloadButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_DOWNLOAD)));
|
||||
SendMessageW(hUninstallButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNINSTALL)));
|
||||
ShowWindow(hUninstallButton, SW_HIDE);
|
||||
|
||||
// Set deflaut entry for hApps
|
||||
Insert.item.mask = TVIF_TEXT|TVIF_IMAGE;
|
||||
Insert.item.pszText = Strings[IDS_CHOOSE_CATEGORY];
|
||||
Insert.item.cchTextMax = lstrlenW(Strings[IDS_CHOOSE_CATEGORY]);
|
||||
Insert.item.iImage = 0;
|
||||
SendMessage(hApps, TVM_INSERTITEM, 0, (LPARAM)&Insert);
|
||||
|
||||
// Create Tree Icons
|
||||
hImageList = ImageList_Create(16, 16, ILC_COLORDDB, 1, 1);
|
||||
SendMessageW(hCategories, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)(HIMAGELIST)hImageList);
|
||||
SendMessageW(hApps, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)(HIMAGELIST)hImageList);
|
||||
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_0)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_1)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_2)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_3)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_4)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_5)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_6)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_7)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_8)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_9)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_10)), NULL);
|
||||
|
||||
// Fill the TreeViews
|
||||
AddItems (hCategories, Root.Children, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void ResizeControl (HWND hwnd, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// Make resizing a little easier
|
||||
MoveWindow(hwnd, x1, y1, x2-x1, y2-y1, TRUE);
|
||||
}
|
||||
|
||||
static void DrawBitmap (HDC hdc, int x, int y, HBITMAP hBmp)
|
||||
{
|
||||
BITMAP bm;
|
||||
HDC hdcMem = CreateCompatibleDC(hdc);
|
||||
|
||||
SelectObject(hdcMem, hBmp);
|
||||
GetObject(hBmp, sizeof(bm), &bm);
|
||||
TransparentBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, 0xFFFFFF);
|
||||
|
||||
DeleteDC(hdcMem);
|
||||
}
|
||||
|
||||
static void DrawDescription (HDC hdc, RECT DescriptionRect)
|
||||
{
|
||||
int i;
|
||||
HFONT Font;
|
||||
RECT Rect = {DescriptionRect.left+5, DescriptionRect.top+3, DescriptionRect.right-2, DescriptionRect.top+22};
|
||||
|
||||
// Backgroud
|
||||
Rectangle(hdc, DescriptionRect.left, DescriptionRect.top, DescriptionRect.right, DescriptionRect.bottom);
|
||||
|
||||
// Underline
|
||||
for (i=DescriptionRect.left+1;i<DescriptionRect.right-1;i++)
|
||||
DrawBitmap(hdc, i, DescriptionRect.top+22, hUnderline); // less code then stretching ;)
|
||||
|
||||
// Headline
|
||||
Font = CreateFont(-16 , 0, 0, 0, FW_EXTRABOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
|
||||
SelectObject(hdc, Font);
|
||||
DrawTextW(hdc, DescriptionHeadline, lstrlenW(DescriptionHeadline), &Rect, DT_SINGLELINE|DT_NOPREFIX);
|
||||
DeleteObject(Font);
|
||||
|
||||
// Description
|
||||
Font = CreateFont(-13 , 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
|
||||
SelectObject(hdc, Font);
|
||||
Rect.top += 40;
|
||||
Rect.bottom = DescriptionRect.bottom-2;
|
||||
DrawTextW(hdc, DescriptionText, lstrlenW(DescriptionText), &Rect, DT_WORDBREAK|DT_NOPREFIX); // ToDo: Call TabbedTextOut to draw a nice table
|
||||
DeleteObject(Font);
|
||||
|
||||
}
|
||||
|
||||
void showUninstaller() {
|
||||
int Split_Vertical = 200;
|
||||
RECT Rect;
|
||||
|
||||
GetClientRect(hwnd,&Rect);
|
||||
ShowWindow(hUninstallButton,SW_SHOW);
|
||||
MoveWindow(hDownloadButton,(Split_Vertical+Rect.right-Rect.left)/2,Rect.bottom-Rect.top-45,140,35,TRUE);;
|
||||
}
|
||||
|
||||
void hideUninstaller() {
|
||||
int Split_Vertical = 200;
|
||||
RECT Rect;
|
||||
|
||||
GetClientRect(hwnd,&Rect);
|
||||
ShowWindow(hUninstallButton,SW_HIDE);
|
||||
MoveWindow(hDownloadButton,(Split_Vertical+Rect.right-Rect.left)/2-70,Rect.bottom-Rect.top-45,140,35,TRUE);
|
||||
}
|
||||
|
||||
void searchApp(const WCHAR* AppName, struct Category* Node) {
|
||||
struct Application* CurrentApplication;
|
||||
if (Node->Children)
|
||||
searchApp(AppName, Node->Children);
|
||||
if (Node->Next)
|
||||
searchApp(AppName, Node->Next);
|
||||
CurrentApplication = Node->Apps;
|
||||
while((SelectedApplication == NULL) && (CurrentApplication != NULL)) {
|
||||
if(wcscmp(CurrentApplication->Name,AppName)==0)
|
||||
SelectedApplication = CurrentApplication;
|
||||
CurrentApplication = CurrentApplication->Next;
|
||||
}
|
||||
}
|
||||
|
||||
void ShowSelectedApplication() {
|
||||
ApplicationText[0]=L'\0';
|
||||
if(SelectedApplication->Version[0] != L'\0') {
|
||||
StrCatW(ApplicationText, Strings[IDS_VERSION]);
|
||||
StrCatW(ApplicationText, SelectedApplication->Version);
|
||||
StrCatW(ApplicationText, L"\n");
|
||||
}
|
||||
if(SelectedApplication->Licence[0] != L'\0') {
|
||||
StrCatW(ApplicationText, Strings[IDS_LICENCE]);
|
||||
StrCatW(ApplicationText, SelectedApplication->Licence);
|
||||
StrCatW(ApplicationText, L"\n");
|
||||
}
|
||||
if(SelectedApplication->Maintainer[0] != L'\0') {
|
||||
StrCatW(ApplicationText, Strings[IDS_MAINTAINER]);
|
||||
StrCatW(ApplicationText, SelectedApplication->Maintainer);
|
||||
StrCatW(ApplicationText, L"\n");
|
||||
}
|
||||
if((SelectedApplication->Licence[0] != L'\0') || (SelectedApplication->Version[0] != L'\0') || (SelectedApplication->Maintainer[0] != L'\0'))
|
||||
StrCatW(ApplicationText, L"\n");
|
||||
StrCatW(ApplicationText, SelectedApplication->Description);
|
||||
ShowMessage(SelectedApplication->Name, ApplicationText);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static RECT DescriptionRect;
|
||||
|
||||
switch (Message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
WCHAR wAppName[0x100] = L"";
|
||||
if (strncmp(CmdLine,"add ",4)==0) {
|
||||
CmdLine = CmdLine+4;
|
||||
if(CmdLine[0]==L'\"') {
|
||||
CmdLine++;
|
||||
CmdLine[strlen(CmdLine)-1]=L'\0';
|
||||
}
|
||||
char* aAppName = addDML(CmdLine);
|
||||
MultiByteToWideChar(CP_UTF8, 0, aAppName, -1, wAppName, 0x100);
|
||||
} else if (strncmp(CmdLine,"show ",5)==0) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, CmdLine+5, -1, wAppName, 0x100);
|
||||
}
|
||||
|
||||
if(!SetupControls(hwnd))
|
||||
return -1;
|
||||
|
||||
if(wAppName[0]!=L'\0')
|
||||
searchApp(wAppName, &Root);
|
||||
|
||||
if(SelectedApplication == NULL) {
|
||||
ShowMessage(Strings[IDS_WELCOME_TITLE], Strings[IDS_WELCOME]);
|
||||
} else {
|
||||
ShowSelectedApplication();
|
||||
if(getUninstaller(SelectedApplication, NULL))
|
||||
showUninstaller();
|
||||
else
|
||||
hideUninstaller();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hwnd, &ps);
|
||||
HDC BackbufferHdc = CreateCompatibleDC(hdc);
|
||||
HBITMAP BackbufferBmp = CreateCompatibleBitmap(hdc, ps.rcPaint.right, ps.rcPaint.bottom);
|
||||
SelectObject(BackbufferHdc, BackbufferBmp);
|
||||
|
||||
FillRect(BackbufferHdc, &ps.rcPaint, CreateSolidBrush(RGB(235,235,235)));
|
||||
DrawBitmap(BackbufferHdc, 10, 12, hLogo);
|
||||
DrawDescription(BackbufferHdc, DescriptionRect);
|
||||
|
||||
BitBlt(hdc, 0, 0, ps.rcPaint.right, ps.rcPaint.bottom, BackbufferHdc, 0, 0, SRCCOPY);
|
||||
DeleteObject(BackbufferBmp);
|
||||
DeleteDC(BackbufferHdc);
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if(HIWORD(wParam) == BN_CLICKED)
|
||||
{
|
||||
if (lParam == (LPARAM)hDownloadButton)
|
||||
{
|
||||
if(SelectedApplication) {
|
||||
DWORD ThreadId;
|
||||
CreateThread(NULL, 0, InstallThreadFunc, SelectedApplication, 0, &ThreadId);
|
||||
} else
|
||||
ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]);
|
||||
}
|
||||
else if (lParam == (LPARAM)hUninstallButton)
|
||||
{
|
||||
if(SelectedApplication) {
|
||||
DWORD ThreadId;
|
||||
CreateThread(NULL, 0, UninstallThreadFunc, SelectedApplication, 0, &ThreadId);
|
||||
hideUninstaller();
|
||||
} else
|
||||
ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]);
|
||||
}
|
||||
else if (lParam == (LPARAM)hUpdateButton)
|
||||
{
|
||||
ShowMessage(Strings[IDS_UPDATE_TITLE], Strings[IDS_UPDATE]);
|
||||
}
|
||||
else if (lParam == (LPARAM)hHelpButton)
|
||||
{
|
||||
ShowMessage(Strings[IDS_HELP_TITLE], Strings[IDS_HELP]);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR data = (LPNMHDR)lParam;
|
||||
if(data->code == TVN_SELCHANGED)
|
||||
{
|
||||
BOOL bShowUninstaller = FALSE;
|
||||
if(data->hwndFrom == hCategories)
|
||||
{
|
||||
struct Category* Category = (struct Category*) ((LPNMTREEVIEW)lParam)->itemNew.lParam;
|
||||
CategoryChoosen (hApps, Category);
|
||||
}
|
||||
else if(data->hwndFrom == hApps)
|
||||
{
|
||||
SelectedApplication = (struct Application*) ((LPNMTREEVIEW)lParam)->itemNew.lParam;
|
||||
if(SelectedApplication)
|
||||
{
|
||||
ShowSelectedApplication();
|
||||
if(getUninstaller(SelectedApplication, NULL)) {
|
||||
bShowUninstaller = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bShowUninstaller)
|
||||
showUninstaller();
|
||||
else
|
||||
hideUninstaller();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZING:
|
||||
{
|
||||
LPRECT pRect = (LPRECT)lParam;
|
||||
if (pRect->right-pRect->left < 520)
|
||||
pRect->right = pRect->left + 520;
|
||||
|
||||
if (pRect->bottom-pRect->top < 300)
|
||||
pRect->bottom = pRect->top + 300;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
int Split_Hozizontal = (HIWORD(lParam)-(45+60))/2 + 60;
|
||||
int Split_Vertical = 200;
|
||||
|
||||
ResizeControl(hCategories, 10, 60, Split_Vertical, HIWORD(lParam)-10);
|
||||
ResizeControl(hApps, Split_Vertical+5, 60, LOWORD(lParam)-10, Split_Hozizontal);
|
||||
RECT Rect = {Split_Vertical+5, Split_Hozizontal+5, LOWORD(lParam)-10, HIWORD(lParam)-50};
|
||||
DescriptionRect = Rect;
|
||||
|
||||
MoveWindow(hHelpButton, LOWORD(lParam)-50, 10, 40, 40, TRUE);
|
||||
MoveWindow(hUpdateButton, LOWORD(lParam)-100, 10, 40, 40, TRUE);
|
||||
if(IsWindowVisible(hUninstallButton))
|
||||
MoveWindow(hDownloadButton, (Split_Vertical+LOWORD(lParam))/2, HIWORD(lParam)-45, 140, 35, TRUE);
|
||||
else
|
||||
MoveWindow(hDownloadButton, (Split_Vertical+LOWORD(lParam))/2-70, HIWORD(lParam)-45, 140, 35, TRUE);
|
||||
MoveWindow(hUninstallButton, (Split_Vertical+LOWORD(lParam))/2-140, HIWORD(lParam)-45, 140, 35, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
DeleteObject(hLogo);
|
||||
if(Root.Children)
|
||||
FreeTree(Root.Children);
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc (hwnd, Message, wParam, lParam);
|
||||
}
|
||||
|
||||
INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
|
||||
LPSTR lpCmdLine, INT nCmdShow)
|
||||
{
|
||||
int i;
|
||||
WNDCLASSEXW WndClass = {0};
|
||||
MSG msg;
|
||||
|
||||
InitCommonControls();
|
||||
CmdLine = lpCmdLine;
|
||||
|
||||
// Load strings
|
||||
for(i=0; i<STRING_COUNT; i++)
|
||||
LoadStringW(hInstance, i, Strings[i], MAX_STRING_LENGHT); // if you know a better method please tell me.
|
||||
|
||||
// Create the window
|
||||
WndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
WndClass.lpszClassName = L"Downloader";
|
||||
WndClass.lpfnWndProc = WndProc;
|
||||
WndClass.hInstance = hInstance;
|
||||
WndClass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
|
||||
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
|
||||
RegisterClassExW(&WndClass);
|
||||
|
||||
hwnd = CreateWindowW(L"Downloader",
|
||||
Strings[IDS_WINDOW_TITLE],
|
||||
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
600, 550,
|
||||
NULL, NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
// Show it
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
// Message Loop
|
||||
while(GetMessage(&msg,NULL,0,0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<installfile base="packagetree/internet/browser">firefox1509.dml</installfile>
|
||||
<installfile base="packagetree/internet/browser">firefox2001.dml</installfile>
|
|
@ -0,0 +1,7 @@
|
|||
<application name="Firefox 1.5" target="internet\browser\firefox.1.5.0.9.dml">
|
||||
<regname>Mozilla Firefox (1.5)</regname>
|
||||
<licence>MPL/GPL/LGPL</licence>
|
||||
<version>1.5.0.9</version>
|
||||
<description>The most popular and one of the best free WebBrowsers out there.</description>
|
||||
<location>http://ftp-mozilla.netscape.com/pub/mozilla.org/firefox/releases/1.5.0.9/win32/en-US/Firefox%20Setup%201.5.0.9.exe</location>
|
||||
</application>
|
|
@ -0,0 +1,7 @@
|
|||
<application name="Firefox 2.0" target="internet\browser\firefox.2.0.0.1.dml">
|
||||
<regname>Mozilla Firefox (2.0.0.1)</regname>
|
||||
<licence>MPL/GPL/LGPL</licence>
|
||||
<version>2.0.0.1</version>
|
||||
<description>The most popular and one of the best free WebBrowsers out there.</description>
|
||||
<location>http://ftp-mozilla.netscape.com/pub/mozilla.org/firefox/releases/latest/win32/en-US/Firefox%20Setup%202.0.0.1.exe</location>
|
||||
</application>
|
54
rosapps/downloader/packagetree/internet/category.xml
Normal file
|
@ -0,0 +1,54 @@
|
|||
<category name="Internet & Network" icon="1">
|
||||
<import folder="internet\browser" />
|
||||
<import folder="internet\email" />
|
||||
<import folder="internet\ftp" />
|
||||
<import folder="internet\chat" />
|
||||
<import folder="internet\filesharing" />
|
||||
<import folder="internet\remotecontrol" />
|
||||
<import folder="internet\server" />
|
||||
<import folder="internet\monitoring" />
|
||||
<import folder="internet\security" />
|
||||
<import folder="internet\streaming" />
|
||||
<import folder="internet\other" />
|
||||
<application name="Thunderbird">
|
||||
<regname>Mozilla Thunderbird (1.5)</regname>
|
||||
<licence>MPL/GPL/LGPL</licence>
|
||||
<version>1.5.0.9</version>
|
||||
<description>The most popular and one of the best free MailClients out there.</description>
|
||||
<location>http://ftp-mozilla.netscape.com/pub/mozilla.org/thunderbird/releases/latest/win32/en-US/Thunderbird%20Setup%201.5.0.9.exe</location>
|
||||
</application>
|
||||
<application name="SeaMonkey">
|
||||
<regname>SeaMonkey (1.0.7)</regname>
|
||||
<version>1.0.7</version>
|
||||
<description>Mozilla Suite is alive. This is the one and only Browser, Mail, Chat, Composer bundle you will ever need.</description>
|
||||
<location>http://ftp-mozilla.netscape.com/pub/mozilla.org/seamonkey/releases/1.0.7/seamonkey-1.0.7.en-US.win32.installer.exe</location>
|
||||
</application>
|
||||
<application name="Mozilla ActiveX Control">
|
||||
<regname>Mozilla ActiveX Control v1.7.12 (ReactOS special)</regname>
|
||||
<version>1.7.12</version>
|
||||
<description>Essential Component to get ReactOS Explorer's and other application's Internet Browsing feature running.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/reactos/MozillaControl1712-ReactOS.exe</location>
|
||||
</application>
|
||||
<application name="Off By One Browser">
|
||||
<regname>The Off By One Web Browser</regname>
|
||||
<description>The Off By One Browser is a very small and fast web browser with full HTML 3.2 support.</description>
|
||||
<location>http://offbyone.com/offbyone/images/OffByOneSetup.exe</location>
|
||||
</application>
|
||||
<application name="Samba TNG">
|
||||
<description>This tool allows you to access your Windows shared folders/printers with ReactOS.</description>
|
||||
<location>http://svn.reactos.org/packages/samba-tng.exe</location>
|
||||
</application>
|
||||
<application name="Miranda IM">
|
||||
<regname>Miranda IM</regname>
|
||||
<version>0.5.1</version>
|
||||
<description>Open source multiprotocol instant messaging application - May not work completely.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/miranda/miranda-im-v0.5.1-unicode.exe</location>
|
||||
</application>
|
||||
<application name="Putty">
|
||||
<regname>PuTTY version 0.59</regname>
|
||||
<licence>MIT</licence>
|
||||
<version>0.59</version>
|
||||
<description>A free SSH, Telnet, rlogin, and raw TCP client.</description>
|
||||
<location>http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.59-installer.exe</location>
|
||||
</application>
|
||||
</category>
|
6
rosapps/downloader/packagetree/internet/internet.rbuild
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<directory name="browser">
|
||||
<xi:include href="browser/browser.rbuild" />
|
||||
</directory>
|
||||
<installfile base="packagetree/internet">category.xml</installfile>
|
9
rosapps/downloader/packagetree/packagetree.rbuild
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<directory name="internet">
|
||||
<xi:include href="internet/internet.rbuild" />
|
||||
</directory>
|
||||
<directory name="script">
|
||||
<xi:include href="script/script.rbuild" />
|
||||
</directory>
|
||||
<installfile base="packagetree">tree.xml</installfile>
|
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
<download url="%location%" file="%TEMP%\%location_file%" />
|
||||
<exec file="%TEMP%\%location_file%" />
|
||||
<del file="%TEMP%\%location_file%" />
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
<exec file="%regname_uninstaller%" />
|
3
rosapps/downloader/packagetree/script/script.rbuild
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0"?>
|
||||
<installfile base="packagetree/script">default_install.xml</installfile>
|
||||
<installfile base="packagetree/script">default_uninstall.xml</installfile>
|
142
rosapps/downloader/packagetree/tree.xml
Normal file
|
@ -0,0 +1,142 @@
|
|||
<tree Version="1"> <!-- Application version this tree is made for -->
|
||||
<import file="internet\category.xml" />
|
||||
<category name="Office" icon="2">
|
||||
<application name="Abiword">
|
||||
<regname>"AbiWord 2.4.1 (remove only)"</regname>
|
||||
<version>2.4.1</version>
|
||||
<description>Word processor.</description>
|
||||
<location>http://www.abiword.org/downloads/abiword/2.4.1/Windows/abiword-setup-2.4.1.exe</location>
|
||||
</application>
|
||||
<application name="OpenOffice">
|
||||
<regname>OpenOffice.org 2.1</regname>
|
||||
<version>2.1.0</version>
|
||||
<description>THE Open Source Office Suite.</description>
|
||||
<location>http://ftp.tu-chemnitz.de/pub/openoffice-extended//stable/2.1.0/OOo_2.1.0_Win32Intel_install_en-US.exe</location>
|
||||
</application>
|
||||
</category>
|
||||
<category name="Graphics" icon="3">
|
||||
<application name="IrfanView">
|
||||
<regname>IrfanView (remove only)</regname>
|
||||
<version>3.99</version>
|
||||
<description>Viewer for all kinds of graphics/audio files/video files.</description>
|
||||
<location>http://gd.tuwien.ac.at/graphics/irfanview/iview399.exe</location>
|
||||
</application>
|
||||
<application name="IrfanView Plugins">
|
||||
<version>3.99</version>
|
||||
<description>Additional Plugins for supporting more file types.</description>
|
||||
<location>http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_399.exe</location>
|
||||
</application>
|
||||
<application name="TuxPaint">
|
||||
<regname>Tux Paint 0.9.16</regname>
|
||||
<version>0.9.16</version>
|
||||
<description>An open source bitmap graphics editor geared towards young children.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/tuxpaint/tuxpaint-0.9.16-win32-installer.exe</location>
|
||||
</application>
|
||||
</category>
|
||||
<category name="Multimedia" icon="4">
|
||||
</category>
|
||||
<category name="Development" icon="5">
|
||||
<application name="ReactOS Build Environment">
|
||||
<regname>ReactOS Build Environment 0.3.4</regname>
|
||||
<version>0.3.4</version>
|
||||
<description>Allows you to build the ReactOS Source. For more instructions see ReactOS wiki.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/reactos/RosBE-0.3.4.exe</location>
|
||||
</application>
|
||||
<application name="MinGW">
|
||||
<regname>MinGW 5.1.3</regname>
|
||||
<version>5.1.3</version>
|
||||
<description>A Port of the GNU toolchain with GCC, GDB, GNU make, etc.</description>
|
||||
<location>http://puzzle.dl.sourceforge.net/sourceforge/mingw/MinGW-5.1.3.exe</location>
|
||||
</application>
|
||||
<application name="FreeBASIC">
|
||||
<regname>FreeBASIC 0.16b</regname>
|
||||
<version>0.16b</version>
|
||||
<description>Open Source Basic Compiler. The Basic syntax is compatible to QBASIC.</description>
|
||||
<location>http://switch.dl.sourceforge.net/sourceforge/fbc/FreeBASIC-v0.16b-win32.exe</location>
|
||||
</application>
|
||||
</category>
|
||||
<category name="Games & Fun" icon="6">
|
||||
<application name="ScummVM">
|
||||
<regname>ScummVM 0.9.1</regname>
|
||||
<version>0.9.1</version>
|
||||
<description>SamNMax, Day of Tentacle, etc on ReactOS</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/scummvm/scummvm-0.9.1-win32.exe</location>
|
||||
</application>
|
||||
<application name="Tile World">
|
||||
<description>Nice Clone of Chip's Challenge originally made for the Atari Lynx. Includes free CCLP2 Graphics Pack, so you dont need the copyrighted Original.</description>
|
||||
<location>http://www.muppetlabs.com/~breadbox/pub/software/tworld/tworld-1.3.0-win32-CCLP2.exe</location>
|
||||
</application>
|
||||
<application name="OpenTTD">
|
||||
<regname>OpenTTD 0.5.0</regname>
|
||||
<version>0.5.0-RC5</version>
|
||||
<description>Open-source-clone of the "Transport Tycoon Deluxe" game-engine. You need a copy of Transport Tycoon.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/openttd/openttd-0.5.0-RC5-win32.exe</location>
|
||||
</application>
|
||||
<application name="LBreakout2">LBreakout2 2.4.1
|
||||
<regname>LBreakout2 2.4.1</regname>
|
||||
<version>2.4.1</version>
|
||||
<description>Breakout Clone using SDL libs.</description>
|
||||
<location>http://switch.dl.sourceforge.net/sourceforge/lgames/lbreakout2-2.4.1-win32.exe</location>
|
||||
</application>
|
||||
<application name="LGeneral">
|
||||
<regname>LGeneral 1.1</regname>
|
||||
<version>1.1</version>
|
||||
<description>Panzer General Clone using SDL libs.</description>
|
||||
<location>http://kent.dl.sourceforge.net/sourceforge/lgames/lgeneral-1.1-win32.exe</location>
|
||||
</application>
|
||||
<application name="LMarbles">
|
||||
<regname>LMarbles 1.0.6</regname>
|
||||
<version>1.0.6</version>
|
||||
<description>Atomix Clone using SDL libs.</description>
|
||||
<location>http://heanet.dl.sourceforge.net/sourceforge/lgames/lmarbles-1.0.6-win32.exe</location>
|
||||
</application>
|
||||
</category>
|
||||
<category name="Tools" icon="7">
|
||||
<application name="7-Zip">
|
||||
<regname>7-Zip 4.42</regname>
|
||||
<version>4.42</version>
|
||||
<description>Utility to create and open 7zip, zip, tar, rar and other archive files.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/sevenzip/7z442.exe</location>
|
||||
</application>
|
||||
<application name="uTorrent">
|
||||
<regname>uTorrent</regname>
|
||||
<version>1.6</version>
|
||||
<description>Small and fast Torrent Client.</description>
|
||||
<location>http://download.utorrent.com/1.6/uTorrent-1.6-install.exe</location>
|
||||
</application>
|
||||
<application name="Audio Grabber">
|
||||
<regname>Audiograbber 1.83 SE </regname>
|
||||
<version>1.83 SE</version>
|
||||
<description>A very good CD Ripper/Audio File Converter.</description>
|
||||
<location>http://www.audiograbber.de/files/342677432/agsetup183se.exe</location>
|
||||
</application>
|
||||
</category>
|
||||
<category name="Others" icon="8">
|
||||
<application name="Simple Direct Media Layer (SDL) Runtime">
|
||||
<regname>SDL Runtime</regname>
|
||||
<version>1.2.11</version>
|
||||
<description>Needed for many Open Source Games to run. You need 7-Zip or a similar Utility to extract it.</description>
|
||||
<location>http://ovh.dl.sourceforge.net/sourceforge/libsdl/SDL-1.2.11-win32.zip</location>
|
||||
<installscript>
|
||||
<load file="test.xml" />
|
||||
<unzip />
|
||||
<download url="%location%" file="%TEMP%\%location_file%" />
|
||||
<unzip file="%TEMP%\%location_file%" outdir="%SystemRoot%\System32" />
|
||||
<exec file="notepad %SystemRoot%\System32\README-SDL.txt" />
|
||||
<del file="%TEMP%\%location_file%" />
|
||||
<adduninstaller regname="%regname%" file="downloader.exe show %name%" />
|
||||
</installscript>
|
||||
<uninstallscript>
|
||||
<del file="%SystemRoot%\System32\SDL.dll" />
|
||||
<del file="%SystemRoot%\System32\README-SDL.txt" />
|
||||
<removeuninstaller regname="%regname%" />
|
||||
<message text="Uninstall complete." />
|
||||
</uninstallscript>
|
||||
</application>
|
||||
<application name="DOSBox">
|
||||
<version>0.65</version>
|
||||
<description>DOSBox is a DOS emulator.</description>
|
||||
<location>http://puzzle.dl.sourceforge.net/sourceforge/dosbox/DOSBox0.65-win32-installer.exe</location>
|
||||
</application>
|
||||
</category>
|
||||
</tree>
|
48
rosapps/downloader/resources.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
#define IDI_MAIN 0x0
|
||||
#define IDB_UNDERLINE 0x100
|
||||
#define IDB_LOGO 0x101
|
||||
#define IDB_HELP 0x102
|
||||
#define IDB_UPDATE 0x103
|
||||
#define IDB_DOWNLOAD 0x104
|
||||
#define IDB_UNINSTALL 0x105
|
||||
#define IDB_TREEVIEW_ICON_0 0x900
|
||||
#define IDB_TREEVIEW_ICON_1 0x901
|
||||
#define IDB_TREEVIEW_ICON_2 0x902
|
||||
#define IDB_TREEVIEW_ICON_3 0x903
|
||||
#define IDB_TREEVIEW_ICON_4 0x904
|
||||
#define IDB_TREEVIEW_ICON_5 0x905
|
||||
#define IDB_TREEVIEW_ICON_6 0x906
|
||||
#define IDB_TREEVIEW_ICON_7 0x907
|
||||
#define IDB_TREEVIEW_ICON_8 0x908
|
||||
#define IDB_TREEVIEW_ICON_9 0x909
|
||||
#define IDB_TREEVIEW_ICON_10 0x910
|
||||
#define IDD_DOWNLOAD 0x100
|
||||
#define IDC_PROGRESS 0x1000
|
||||
#define IDC_STATUS 0x1001
|
||||
#define IDC_REMOVE 0x1002
|
||||
|
||||
#define IDS_WINDOW_TITLE 0
|
||||
#define IDS_WELCOME_TITLE 1
|
||||
#define IDS_WELCOME 2
|
||||
#define IDS_NO_APP_TITLE 3
|
||||
#define IDS_NO_APP 4
|
||||
#define IDS_UPDATE_TITLE 5
|
||||
#define IDS_UPDATE 6
|
||||
#define IDS_HELP_TITLE 7
|
||||
#define IDS_HELP 8
|
||||
#define IDS_NO_APPS 9
|
||||
#define IDS_CHOOSE_APP 10
|
||||
#define IDS_CHOOSE_SUB 11
|
||||
#define IDS_CHOOSE_CATEGORY 12
|
||||
#define IDS_CHOOSE_BOTH 13
|
||||
#define IDS_XMLERROR_1 14
|
||||
#define IDS_XMLERROR_2 15
|
||||
#define IDS_DOWNLOAD_ERROR 16
|
||||
#define IDS_UNZIP_ERROR 17
|
||||
#define IDS_VERSION 18
|
||||
#define IDS_LICENCE 19
|
||||
#define IDS_MAINTAINER 20
|
||||
|
||||
#define STRING_COUNT 21
|
||||
#define MAX_STRING_LENGHT 0x100
|
BIN
rosapps/downloader/resources/0.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/1.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/10.bmp
Normal file
After Width: | Height: | Size: 824 B |
BIN
rosapps/downloader/resources/2.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/3.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/4.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/5.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/6.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/7.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/8.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
rosapps/downloader/resources/9.bmp
Normal file
After Width: | Height: | Size: 824 B |
BIN
rosapps/downloader/resources/download.bmp
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
rosapps/downloader/resources/help.bmp
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
rosapps/downloader/resources/logo.bmp
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
rosapps/downloader/resources/main.ico
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
rosapps/downloader/resources/underline.bmp
Normal file
After Width: | Height: | Size: 170 B |
BIN
rosapps/downloader/resources/uninstall.bmp
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
rosapps/downloader/resources/update.bmp
Normal file
After Width: | Height: | Size: 3.1 KiB |
27
rosapps/downloader/rsrc.rc
Normal file
|
@ -0,0 +1,27 @@
|
|||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
|
||||
IDI_MAIN ICON DISCARDABLE "resources/main.ico"
|
||||
IDB_LOGO BITMAP DISCARDABLE "resources/logo.bmp"
|
||||
IDB_HELP BITMAP DISCARDABLE "resources/help.bmp"
|
||||
IDB_UPDATE BITMAP DISCARDABLE "resources/update.bmp"
|
||||
IDB_DOWNLOAD BITMAP DISCARDABLE "resources/download.bmp"
|
||||
IDB_UNINSTALL BITMAP DISCARDABLE "resources/uninstall.bmp"
|
||||
IDB_UNDERLINE BITMAP DISCARDABLE "resources/underline.bmp"
|
||||
IDB_TREEVIEW_ICON_0 BITMAP DISCARDABLE "resources/0.bmp"
|
||||
IDB_TREEVIEW_ICON_1 BITMAP DISCARDABLE "resources/1.bmp"
|
||||
IDB_TREEVIEW_ICON_2 BITMAP DISCARDABLE "resources/2.bmp"
|
||||
IDB_TREEVIEW_ICON_3 BITMAP DISCARDABLE "resources/3.bmp"
|
||||
IDB_TREEVIEW_ICON_4 BITMAP DISCARDABLE "resources/4.bmp"
|
||||
IDB_TREEVIEW_ICON_5 BITMAP DISCARDABLE "resources/5.bmp"
|
||||
IDB_TREEVIEW_ICON_6 BITMAP DISCARDABLE "resources/6.bmp"
|
||||
IDB_TREEVIEW_ICON_7 BITMAP DISCARDABLE "resources/7.bmp"
|
||||
IDB_TREEVIEW_ICON_8 BITMAP DISCARDABLE "resources/8.bmp"
|
||||
IDB_TREEVIEW_ICON_9 BITMAP DISCARDABLE "resources/9.bmp"
|
||||
IDB_TREEVIEW_ICON_10 BITMAP DISCARDABLE "resources/10.bmp"
|
||||
|
||||
|
||||
#include "translations/de.rc"
|
||||
#include "translations/en.rc"
|
||||
#include "translations/fr.rc"
|
||||
#include "translations/id.rc"
|
||||
#include "translations/it.rc"
|
246
rosapps/downloader/script.c
Normal file
|
@ -0,0 +1,246 @@
|
|||
/* PROJECT: ReactOS Downloader
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/applications/downloader/script.c
|
||||
* PURPOSE: Run (un/)installscript
|
||||
* PROGRAMMERS: Lester Kortenhoeven
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "resources.h"
|
||||
#include "structures.h"
|
||||
|
||||
extern BOOL getUninstaller(struct Application*, WCHAR*);
|
||||
extern INT_PTR CALLBACK DownloadProc (HWND, UINT, WPARAM, LPARAM);
|
||||
extern WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
|
||||
|
||||
static void DownloadScriptFunc (WCHAR* URL, WCHAR* File) {
|
||||
struct lParamDownload* lParam;
|
||||
lParam = malloc(sizeof(struct lParamDownload));
|
||||
lParam->URL = URL;
|
||||
lParam->File = File;
|
||||
DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_DOWNLOAD), 0, DownloadProc, (LPARAM)lParam);
|
||||
free(lParam);
|
||||
}
|
||||
|
||||
static void ExecScriptFunc(WCHAR* Arg) {
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cb=sizeof(si);
|
||||
CreateProcessW(NULL,Arg,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
|
||||
CloseHandle(pi.hThread);
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
|
||||
|
||||
static void DelScriptFunc(WCHAR* Arg) {
|
||||
DeleteFileW(Arg);
|
||||
}
|
||||
|
||||
static BOOL UnzipScriptFunc(WCHAR* File, WCHAR* Outdir) {
|
||||
HKEY hKey;
|
||||
DWORD Type = 0;
|
||||
WCHAR ExecStr[0x100];
|
||||
DWORD currentlengt = 0x100;
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\7-Zip",0,KEY_READ,&hKey) == ERROR_SUCCESS) {
|
||||
if (RegQueryValueExW(hKey,L"Path",0,&Type,(LPBYTE)ExecStr,¤tlengt) == ERROR_SUCCESS) {
|
||||
if (File[0] != L'\0') {
|
||||
wcsncat(ExecStr,L"\\7z.exe x ",0x100-currentlengt);
|
||||
currentlengt = lstrlenW(ExecStr);
|
||||
wcsncat(ExecStr,File,0x100-currentlengt);
|
||||
currentlengt = lstrlenW(ExecStr);
|
||||
wcsncat(ExecStr,L" -o",0x100-currentlengt);
|
||||
currentlengt = lstrlenW(ExecStr);
|
||||
wcsncat(ExecStr,Outdir,0x100-currentlengt);
|
||||
ExecScriptFunc(ExecStr);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
MessageBoxW(0,Strings[IDS_UNZIP_ERROR],0,0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void AddUninstallerScriptFunc(WCHAR* RegName, WCHAR* File) {
|
||||
HKEY hKey1;
|
||||
HKEY hKey2;
|
||||
LPDWORD dispos = NULL;
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_WRITE,&hKey1) == ERROR_SUCCESS)
|
||||
if (RegCreateKeyEx(hKey1,RegName,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey2,dispos) == ERROR_SUCCESS) {
|
||||
RegSetValueExW(hKey2,L"DisplayName",0,REG_SZ,(BYTE*)RegName,(lstrlen(RegName)+1)*sizeof(WCHAR));
|
||||
RegSetValueExW(hKey2,L"UninstallString",0,REG_SZ,(BYTE*)File,(lstrlen(File)+1)*sizeof(WCHAR));
|
||||
}
|
||||
RegCloseKey(hKey2);
|
||||
RegCloseKey(hKey1);
|
||||
}
|
||||
|
||||
static void RemoveUninstallerScriptFunc(WCHAR* RegName) {
|
||||
HKEY hKey1;
|
||||
HKEY hKey2;
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_WRITE,&hKey1) == ERROR_SUCCESS) {
|
||||
if (RegOpenKeyExW(hKey1,RegName,0,KEY_WRITE,&hKey2) == ERROR_SUCCESS) {
|
||||
RegDeleteValueW(hKey2,L"DisplayName");
|
||||
RegDeleteValueW(hKey2,L"UninstallString");
|
||||
RegCloseKey(hKey2);
|
||||
}
|
||||
// RegDeleteKeyW(hKey1,RegName);
|
||||
}
|
||||
RegCloseKey(hKey1);
|
||||
}
|
||||
|
||||
static void MessageScriptFunc(WCHAR* Text) {
|
||||
MessageBoxW(0,Text,Strings[IDS_WINDOW_TITLE],0);
|
||||
}
|
||||
|
||||
extern void LoadScriptFunc(WCHAR*, struct ScriptElement*);
|
||||
|
||||
static void RunScript(struct Application* App, struct ScriptElement* Script) {
|
||||
BOOL bRun = TRUE;
|
||||
struct ScriptElement* p = Script;
|
||||
INT SizeB = 0x100;
|
||||
INT SizeA = sizeof(p->Arg)/sizeof(*(p->Arg));
|
||||
INT i;
|
||||
int currentlengt = 0;
|
||||
WCHAR ArgBuffer[SizeA][SizeB];
|
||||
WCHAR BufferA[SizeB];
|
||||
WCHAR BufferB[SizeB];
|
||||
WCHAR BufferC[SizeB];
|
||||
WCHAR* Pos1;
|
||||
WCHAR* Pos2;
|
||||
WCHAR* Pos3 = NULL;
|
||||
BOOL bNext;
|
||||
while(bRun && (p != NULL)) {
|
||||
|
||||
for(i=0; i<SizeA; i++) {
|
||||
bNext = TRUE;
|
||||
wcscpy(BufferA, p->Arg[i]);
|
||||
Pos1 = BufferA;
|
||||
Pos2 = wcschr(Pos1, L'%');
|
||||
if(!Pos2) {
|
||||
wcscpy(ArgBuffer[i], Pos1);
|
||||
break;
|
||||
}
|
||||
Pos2[0] = L'\0';
|
||||
wcscpy(BufferB, Pos1);
|
||||
Pos1 = Pos2 + 1;
|
||||
Pos2 = wcschr(Pos1, L'%');
|
||||
while (Pos2) {
|
||||
Pos2[0] = L'\0';
|
||||
if(bNext) {
|
||||
if (wcscmp(Pos1, L"name") == 0) {
|
||||
Pos3 = App->Name;
|
||||
} else if (wcscmp(Pos1, L"regname") == 0) {
|
||||
Pos3 = App->RegName;
|
||||
} else if (wcscmp(Pos1, L"version") == 0) {
|
||||
Pos3 = App->Version;
|
||||
} else if (wcscmp(Pos1, L"maintainer") == 0) {
|
||||
Pos3 = App->Maintainer;
|
||||
} else if (wcscmp(Pos1, L"licence") == 0) {
|
||||
Pos3 = App->Licence;
|
||||
} else if (wcscmp(Pos1, L"description") == 0) {
|
||||
Pos3 = App->Description;
|
||||
} else if (wcscmp(Pos1, L"location") == 0) {
|
||||
Pos3 = App->Location;
|
||||
} else if (wcscmp(Pos1, L"regname_uninstaller") == 0) {
|
||||
if (!getUninstaller(App, BufferC)) {
|
||||
BufferC[0] = '\0';
|
||||
}
|
||||
Pos3 = BufferC;
|
||||
} else if (wcscmp(Pos1, L"location_file") == 0) {
|
||||
Pos3 = wcsrchr(App->Location, L'/');
|
||||
if(Pos3 == NULL) {
|
||||
BufferC[0] = '\0';
|
||||
Pos3 = BufferC;
|
||||
} else {
|
||||
Pos3++;
|
||||
}
|
||||
} else {
|
||||
Pos3 = _wgetenv(Pos1);
|
||||
}
|
||||
bNext = !(Pos3);
|
||||
if (bNext) {
|
||||
Pos3 = Pos1;
|
||||
currentlengt = lstrlenW(BufferB);
|
||||
wcsncat(BufferB, L"%", SizeB-currentlengt);
|
||||
}
|
||||
} else {
|
||||
Pos3 = Pos1;
|
||||
bNext = TRUE;
|
||||
}
|
||||
currentlengt = lstrlenW(BufferB);
|
||||
wcsncat(BufferB, Pos3, SizeB-currentlengt);
|
||||
Pos1 = Pos2 + 1;
|
||||
Pos2 = wcschr(Pos1, L'%');
|
||||
}
|
||||
if (bNext) {
|
||||
wcsncat(BufferB, L"%", SizeB-currentlengt);
|
||||
}
|
||||
currentlengt = lstrlenW(BufferB);
|
||||
wcsncat(BufferB, Pos1, SizeB-currentlengt);
|
||||
wcscpy(ArgBuffer[i], BufferB);
|
||||
}
|
||||
|
||||
if (wcscmp(p->Func, L"download") == 0) {
|
||||
DownloadScriptFunc(ArgBuffer[0], ArgBuffer[1]);
|
||||
} else if (wcscmp(p->Func, L"exec") == 0) {
|
||||
ExecScriptFunc(ArgBuffer[0]);
|
||||
} else if (wcscmp(p->Func, L"del") == 0) {
|
||||
DelScriptFunc(ArgBuffer[0]);
|
||||
} else if (wcscmp(p->Func, L"unzip") == 0) {
|
||||
bRun = UnzipScriptFunc(ArgBuffer[0], ArgBuffer[1]);
|
||||
} else if (wcscmp(p->Func, L"adduninstaller") == 0) {
|
||||
AddUninstallerScriptFunc(ArgBuffer[0], ArgBuffer[1]);
|
||||
} else if (wcscmp(p->Func, L"removeuninstaller") == 0) {
|
||||
RemoveUninstallerScriptFunc(ArgBuffer[0]);
|
||||
} else if (wcscmp(p->Func, L"message") == 0) {
|
||||
MessageScriptFunc(ArgBuffer[0]);
|
||||
} else if (wcscmp(p->Func, L"load") == 0) {
|
||||
LoadScriptFunc(ArgBuffer[0],p);
|
||||
}
|
||||
p = p->Next;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD WINAPI InstallThreadFunc(LPVOID Context) {
|
||||
struct Application* App = (struct Application*)Context;
|
||||
|
||||
if(App->InstallScript == NULL){
|
||||
/* Default UninstallScript */
|
||||
struct ScriptElement* Current;
|
||||
Current = malloc(sizeof(struct ScriptElement));
|
||||
App->InstallScript = Current;
|
||||
memset(Current, 0, sizeof(struct ScriptElement));
|
||||
wcscpy(Current->Func, L"load");
|
||||
wcscpy(Current->Arg[0], L"script/default.install.xml");
|
||||
}
|
||||
|
||||
RunScript(App, App->InstallScript);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DWORD WINAPI UninstallThreadFunc(LPVOID Context){
|
||||
struct Application* App = (struct Application*)Context;
|
||||
|
||||
if(App->UninstallScript == NULL){
|
||||
/* Default UninstallScript */
|
||||
struct ScriptElement* Current;
|
||||
Current = malloc(sizeof(struct ScriptElement));
|
||||
App->UninstallScript = Current;
|
||||
memset(Current, 0, sizeof(struct ScriptElement));
|
||||
wcscpy(Current->Func, L"load");
|
||||
wcscpy(Current->Arg[0], L"script/default.uninstall.xml");
|
||||
}
|
||||
|
||||
RunScript(App, App->UninstallScript);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
40
rosapps/downloader/structures.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
struct Application
|
||||
{
|
||||
WCHAR Name[0x100];
|
||||
WCHAR RegName[0x100];
|
||||
WCHAR Version[0x100];
|
||||
WCHAR Maintainer[0x100];
|
||||
WCHAR Licence[0x100];
|
||||
WCHAR Description[0x400];
|
||||
WCHAR Location[0x100];
|
||||
struct Application* Next;
|
||||
struct ScriptElement* InstallScript;
|
||||
struct ScriptElement* UninstallScript;
|
||||
};
|
||||
|
||||
struct Category
|
||||
{
|
||||
WCHAR Name[0x100];
|
||||
//WCHAR Description[0x100];
|
||||
int Icon;
|
||||
HANDLE TreeviewItem;
|
||||
struct Application* Apps;
|
||||
struct Category* Next;
|
||||
struct Category* Children;
|
||||
struct Category* Parent;
|
||||
};
|
||||
|
||||
struct ScriptElement
|
||||
{
|
||||
WCHAR Func[0x100];
|
||||
WCHAR Arg[2][0x100];
|
||||
struct ScriptElement* Next;
|
||||
};
|
||||
|
||||
struct lParamDownload
|
||||
{
|
||||
HWND Dlg;
|
||||
WCHAR* URL;
|
||||
WCHAR* File;
|
||||
};
|
36
rosapps/downloader/translations/de.rc
Normal file
|
@ -0,0 +1,36 @@
|
|||
LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
|
||||
|
||||
IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Download..."
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
|
||||
LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WINDOW_TITLE "Download ! - ReactOS Downloader"
|
||||
IDS_WELCOME_TITLE "Willkommen im ReactOS Downloader"
|
||||
IDS_WELCOME "Bitte wählen Sie links eine Kategorie. Dies ist Version 1.0."
|
||||
IDS_NO_APP_TITLE "Keine Anwendung ausgewählt"
|
||||
IDS_NO_APP "Bitte wählen Sie eine Anwendung, bevor Sie die Download-Schaltfläche betätigen. Wenn Sie Hilfe benötigen, drücken Sie die Hilfe-Schaltfläche in der oberen rechten Ecke."
|
||||
IDS_UPDATE_TITLE "Update"
|
||||
IDS_UPDATE "Diese Funktion wurde noch nicht implementiert."
|
||||
IDS_HELP_TITLE "Hilfe"
|
||||
IDS_HELP "Wählen Sie links eine Kategorie, wählen Sie eine Anwendung und drücken Sie die Download-Schaltfläche. Um die Anwendungsinformationen zu aktualisieren, drücken Sie die Schaltfläche neben der Hilfe-Schaltfläche."
|
||||
IDS_NO_APPS "In dieser Kategorie sind bisher noch keine Anwendungen. Sie können helfen, indem Sie Anwendungen hinzufügen."
|
||||
IDS_CHOOSE_APP "Bitte wählen Sie eine Anwendung."
|
||||
IDS_CHOOSE_SUB "Bitte wählen Sie eine Unterkategorie."
|
||||
IDS_CHOOSE_CATEGORY "Bitte wählen Sie eine Kategorie."
|
||||
IDS_CHOOSE_BOTH "Bitte wählen Sie eine Unterkategorie oder eine Anwendung."
|
||||
IDS_XMLERROR_1 "XML Datei nicht gefunden!"
|
||||
IDS_XMLERROR_2 "XML Datei kann nicht verarbeitet werden!"
|
||||
IDS_DOWNLOAD_ERROR "Die Datei konnte nicht runtergeladen werden.\nBitte prüfen sie, ob eine Verbindung zum Internet besteht."
|
||||
IDS_UNZIP_ERROR "7-Zip nicht gefunden.\nBitte installieren Sie 7-Zip."
|
||||
IDS_VERSION "Version: "
|
||||
IDS_LICENCE "Lizenz: "
|
||||
IDS_MAINTAINER "Maintainer: "
|
||||
END
|
36
rosapps/downloader/translations/en.rc
Normal file
|
@ -0,0 +1,36 @@
|
|||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Download..."
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
|
||||
LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WINDOW_TITLE "Download ! - ReactOS Downloader"
|
||||
IDS_WELCOME_TITLE "Welcome to the ReactOS Downloader"
|
||||
IDS_WELCOME "Please choose a category on the left. This is version 1.0."
|
||||
IDS_NO_APP_TITLE "No application selected"
|
||||
IDS_NO_APP "Please select a Application before you click the download button, if you need assistance please click on the question mark button on the top right corner."
|
||||
IDS_UPDATE_TITLE "Update"
|
||||
IDS_UPDATE "Sorry this feature is not implemented yet."
|
||||
IDS_HELP_TITLE "Help"
|
||||
IDS_HELP "Choose a category on the left, then choose a application and click the download button. To update the application information click the button next to the help button."
|
||||
IDS_NO_APPS "Sorry, there no applications in this category yet. You can help and add more applications."
|
||||
IDS_CHOOSE_APP "Please choose an application."
|
||||
IDS_CHOOSE_SUB "Please choose a subcategory."
|
||||
IDS_CHOOSE_CATEGORY "Please choose a category."
|
||||
IDS_CHOOSE_BOTH "Please choose a subcategory or an application."
|
||||
IDS_XMLERROR_1 "Could not find the xml file !"
|
||||
IDS_XMLERROR_2 "Could not parse the xml file !"
|
||||
IDS_DOWNLOAD_ERROR "Unable to download the file.\nPlease check you internet connection."
|
||||
IDS_UNZIP_ERROR "7-Zip not found.\nPlease install 7-Zip"
|
||||
IDS_VERSION "Version: "
|
||||
IDS_LICENCE "Licence: "
|
||||
IDS_MAINTAINER "Maintainer: "
|
||||
END
|
36
rosapps/downloader/translations/fr.rc
Normal file
|
@ -0,0 +1,36 @@
|
|||
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
|
||||
|
||||
IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Téléchargement..."
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
|
||||
LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
|
||||
PUSHBUTTON "Annuler", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WINDOW_TITLE "Télécharger ! - Téléchargeur de ReactOS"
|
||||
IDS_WELCOME_TITLE "Bienvenue dans le Téléchargeur de ReactOS"
|
||||
IDS_WELCOME "Veuillez choisir une catégorie sur la droite. C'est la version 1.0."
|
||||
IDS_NO_APP_TITLE "Aucune application selectionnée"
|
||||
IDS_NO_APP "Veuillez sélectionner une application avant de cliquer sur le bouton Télécharger, si vous avez besoin d'aide, veuillez cliquer sur le point d'interrogation dans le coin supérieur droit."
|
||||
IDS_UPDATE_TITLE "Mise à jour"
|
||||
IDS_UPDATE "Désolé, cette fonctionnalité n'est pas encore implémentée."
|
||||
IDS_HELP_TITLE "Aide"
|
||||
IDS_HELP "Choisissez une catégorie sur la droite, puis choisissez une application et cliquez sur le bouton Télécharger. Pour mettre à jour les informations sur l'application, cliquez sur le bouton à côté du bouton d'aide."
|
||||
IDS_NO_APPS "Désolé, il n'y a pas encore d'application dans cette catégorie. Vous pouvez contribuer et ajouter plus d'applications."
|
||||
IDS_CHOOSE_APP "Veuillez choisir une application."
|
||||
IDS_CHOOSE_SUB "Veuillez choisir une sous-catégorie."
|
||||
IDS_CHOOSE_CATEGORY "Veuillez choisir une catégorie."
|
||||
IDS_CHOOSE_BOTH "Veuillez choisir une sous-catégorie ou une application."
|
||||
IDS_XMLERROR_1 "Impossible de trouver le fichier xml !"
|
||||
IDS_XMLERROR_2 "Impossible d'analyser le fichier xml !"
|
||||
IDS_DOWNLOAD_ERROR "Impossible de télécharger le fichier.\nVeuillez vérifier votre connexion Internet."
|
||||
IDS_UNZIP_ERROR "7-Zip not found.\nPlease install 7-Zip"
|
||||
IDS_VERSION "Version: "
|
||||
IDS_LICENCE "Licence: "
|
||||
IDS_MAINTAINER "Maintainer: "
|
||||
END
|
36
rosapps/downloader/translations/id.rc
Normal file
|
@ -0,0 +1,36 @@
|
|||
LANGUAGE LANG_INDONESIAN, SUBLANG_DEFAULT
|
||||
|
||||
IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Download..."
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
|
||||
LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
|
||||
PUSHBUTTON "Batal", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WINDOW_TITLE "Download ! - ReactOS Downloader"
|
||||
IDS_WELCOME_TITLE "Selamat datang di ReactOS Downloader"
|
||||
IDS_WELCOME "Silahkan pilih kategori di sebelah kanan. Ini versi 1.0."
|
||||
IDS_NO_APP_TITLE "Tidak ada aplikasi yang dipilih"
|
||||
IDS_NO_APP "Silahkan pilih Aplikasi sebelum anda mengklik tombol download, jika anda membutuhkan asistensi silahkan klik pada tombol di sudut kanan atas."
|
||||
IDS_UPDATE_TITLE "Mutakhirkan"
|
||||
IDS_UPDATE "Maaf fitur ini belum diimplementasikan."
|
||||
IDS_HELP_TITLE "Bantuan"
|
||||
IDS_HELP "Pilih kategori di sisi kiri, lalu pilih aplikasi dan klik tombol download. Untuk memutakhirkan informasi aplikasi klik tombol disebelah tombol bantuan."
|
||||
IDS_NO_APPS "Maaf, belum ada aplikasi dalam kategori ini. Anda dapat membantu dan menambahkan aplikasi lebih banyak."
|
||||
IDS_CHOOSE_APP "Silahkan pilih aplikasi."
|
||||
IDS_CHOOSE_SUB "Silahkan pilih subkategori."
|
||||
IDS_CHOOSE_CATEGORY "Silahkan pilih kategori."
|
||||
IDS_CHOOSE_BOTH "Silahkan pilih subkategori atau aplikasi."
|
||||
IDS_XMLERROR_1 "Tidak dapat menemukan file xml !"
|
||||
IDS_XMLERROR_2 "Tidak dapat mengurai file xml !"
|
||||
IDS_DOWNLOAD_ERROR "Tidak bisa mendownload file.\nSilahkan periksa koneksi internet anda."
|
||||
IDS_UNZIP_ERROR "7-Zip not found.\nPlease install 7-Zip"
|
||||
IDS_VERSION "Versi: "
|
||||
IDS_LICENCE "Lisensi: "
|
||||
IDS_MAINTAINER "Pemelihara: "
|
||||
END
|
36
rosapps/downloader/translations/it.rc
Normal file
|
@ -0,0 +1,36 @@
|
|||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
|
||||
IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Download..."
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
|
||||
LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WINDOW_TITLE "Download ! - ReactOS Downloader"
|
||||
IDS_WELCOME_TITLE "Benvenuto al ReactOS Downloader"
|
||||
IDS_WELCOME "Scegli una categoria a destra. Questa è la versione 1.0."
|
||||
IDS_NO_APP_TITLE "Nessuna applicazione selezionata"
|
||||
IDS_NO_APP "Scegli una Applicazione prima di premere il bottone di download, se serve assistenza clicca sul punto di domanda nell'angolo in alto a destra."
|
||||
IDS_UPDATE_TITLE "Aggiona"
|
||||
IDS_UPDATE "Funzione non ancora implementata."
|
||||
IDS_HELP_TITLE "Aiuto"
|
||||
IDS_HELP "Scegli una categoria a destra, poi scegli una applicazione e clicca il bottone download. Per aggiornare le informazioni sulla applicazione clicca il bottone accanto a quello di aiuto."
|
||||
IDS_NO_APPS "Non ci sono ancora applicazioni in questa categoria. Puoi aiutare aggiungendone altre."
|
||||
IDS_CHOOSE_APP "Scegli una applicazione."
|
||||
IDS_CHOOSE_SUB "Scegli una sottocategoria."
|
||||
IDS_CHOOSE_CATEGORY "Scegli una categoria."
|
||||
IDS_CHOOSE_BOTH "Scegli una sottocategoria o una applicazione."
|
||||
IDS_XMLERROR_1 "File xml non trovato !"
|
||||
IDS_XMLERROR_2 "Impossibile trattare il contenuto del file xml !"
|
||||
IDS_DOWNLOAD_ERROR "Download del file impossibile.\nVerifica la connessione a Internet."
|
||||
IDS_UNZIP_ERROR "7-Zip not found.\nPlease install 7-Zip"
|
||||
IDS_VERSION "Version: "
|
||||
IDS_LICENCE "Licence: "
|
||||
IDS_MAINTAINER "Maintainer: "
|
||||
END
|
525
rosapps/downloader/xml.c
Normal file
|
@ -0,0 +1,525 @@
|
|||
/* PROJECT: ReactOS Downloader
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base\applications\downloader\xml.c
|
||||
* PURPOSE: Parsing of application information xml files
|
||||
* PROGRAMMERS: Maarten Bosma, Lester Kortenhoeven
|
||||
*/
|
||||
|
||||
#include <libs/expat/expat.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#include <io.h>
|
||||
#include "structures.h"
|
||||
#include "resources.h"
|
||||
|
||||
BOOL TagOpen;
|
||||
BOOL InstallScriptOpen;
|
||||
BOOL UninstallScriptOpen;
|
||||
struct Category* Current;
|
||||
struct Application* CurrentApplication;
|
||||
struct ScriptElement* CurrentScript;
|
||||
char DML_Name[0x100];
|
||||
char DML_Target[0x100];
|
||||
char Path [0x100];
|
||||
char CurrentTag [0x100];
|
||||
|
||||
extern WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
|
||||
BOOL ImportXML (const char*);
|
||||
|
||||
void ImportFolder (const char* folder)
|
||||
{
|
||||
WCHAR buffer[0x100];
|
||||
char buffer2[0x100];
|
||||
struct _wfinddata_t Finddata;
|
||||
DWORD Findhandle;
|
||||
buffer[0]='\0';
|
||||
strcpy(buffer2, Path);
|
||||
strncat(buffer2, folder, 0x100-strlen(buffer2));
|
||||
strncat(buffer2, "\\*.dml", 0x100-strlen(buffer2));
|
||||
MultiByteToWideChar(CP_UTF8, 0, buffer2, -1, buffer, 0x100);
|
||||
if((Findhandle=_wfindfirst(buffer, &Finddata)) == -1)
|
||||
return;
|
||||
do {
|
||||
buffer[0]='\0';
|
||||
MultiByteToWideChar(CP_UTF8, 0, folder, -1, buffer, 0x100);
|
||||
wcsncat(buffer, L"\\", 0x100-wcslen(buffer));
|
||||
wcsncat(buffer, Finddata.name, 0x100-wcslen(buffer));
|
||||
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, buffer2, 0x100, NULL, FALSE);
|
||||
ImportXML(buffer2);
|
||||
} while(_wfindnext(Findhandle, &Finddata)==0);
|
||||
_findclose(Findhandle);
|
||||
}
|
||||
|
||||
|
||||
void Script_tag_opened (void* usrdata, const char* tag, const char** arg)
|
||||
{
|
||||
int i;
|
||||
if (!strcmp(tag, "script")) {
|
||||
return;
|
||||
} else if (InstallScriptOpen && (CurrentScript == NULL)) {
|
||||
CurrentApplication->InstallScript = malloc(sizeof(struct ScriptElement));
|
||||
CurrentScript = CurrentApplication->InstallScript;
|
||||
} else if (UninstallScriptOpen && (CurrentScript == NULL)) {
|
||||
CurrentApplication->UninstallScript = malloc(sizeof(struct ScriptElement));
|
||||
CurrentScript = CurrentApplication->UninstallScript;
|
||||
} else if (CurrentScript != NULL) {
|
||||
CurrentScript->Next = malloc(sizeof(struct ScriptElement));
|
||||
CurrentScript = CurrentScript->Next;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
memset(CurrentScript, 0, sizeof(struct ScriptElement));
|
||||
if (!strcmp(tag, "download")) {
|
||||
wcscpy(CurrentScript->Func, L"download");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "file")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[1], 0x100);
|
||||
} else if(!strcmp(arg[i], "url")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "exec")) {
|
||||
wcscpy(CurrentScript->Func, L"exec");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "file")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "del")) {
|
||||
wcscpy(CurrentScript->Func, L"del");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "file")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "unzip")) {
|
||||
wcscpy(CurrentScript->Func, L"unzip");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "file")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
} else if(!strcmp(arg[i], "outdir")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[1], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "adduninstaller")) {
|
||||
wcscpy(CurrentScript->Func, L"adduninstaller");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "regname")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
} else if(!strcmp(arg[i], "file")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[1], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "removeuninstaller")) {
|
||||
wcscpy(CurrentScript->Func, L"removeuninstaller");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "regname")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "message")) {
|
||||
wcscpy(CurrentScript->Func, L"message");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "text")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(tag, "load")) {
|
||||
wcscpy(CurrentScript->Func, L"load");
|
||||
for (i=0; arg[i]; i+=2) {
|
||||
if(!strcmp(arg[i], "file")) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
|
||||
}
|
||||
}
|
||||
} else
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||
}
|
||||
|
||||
|
||||
void tag_opened (void* usrdata, const char* tag, const char** arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!strcmp(tag, "import"))
|
||||
{
|
||||
for (i=0; arg[i]; i+=2)
|
||||
{
|
||||
if(!strcmp(arg[i], "file"))
|
||||
{
|
||||
ImportXML(arg[i+1]);
|
||||
}
|
||||
else if(!strcmp(arg[i], "folder"))
|
||||
{
|
||||
ImportFolder(arg[i+1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!strcmp(tag, "tree") && !CurrentApplication)
|
||||
{
|
||||
// check version
|
||||
}
|
||||
|
||||
else if(!strcmp(tag, "category") && !CurrentApplication)
|
||||
{
|
||||
if (!Current)
|
||||
{
|
||||
Current = malloc(sizeof(struct Category));
|
||||
memset(Current, 0, sizeof(struct Category));
|
||||
}
|
||||
else if (TagOpen)
|
||||
{
|
||||
Current->Children = malloc(sizeof(struct Category));
|
||||
memset(Current->Children, 0, sizeof(struct Category));
|
||||
Current->Children->Parent = Current;
|
||||
Current = Current->Children;
|
||||
}
|
||||
else
|
||||
{
|
||||
Current->Next = malloc(sizeof(struct Category));
|
||||
memset(Current->Next, 0, sizeof(struct Category));
|
||||
Current->Next->Parent = Current->Parent;
|
||||
Current = Current->Next;
|
||||
}
|
||||
TagOpen = TRUE;
|
||||
|
||||
for (i=0; arg[i]; i+=2)
|
||||
{
|
||||
if(!strcmp(arg[i], "name"))
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, Current->Name, 0x100);
|
||||
}
|
||||
if(!strcmp(arg[i], "icon"))
|
||||
{
|
||||
Current->Icon = atoi(arg[i+1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(!strcmp(tag, "application") && !CurrentApplication)
|
||||
{
|
||||
if(Current->Apps)
|
||||
{
|
||||
CurrentApplication = Current->Apps;
|
||||
while(CurrentApplication->Next)
|
||||
CurrentApplication = CurrentApplication->Next;
|
||||
CurrentApplication->Next = malloc(sizeof(struct Application));
|
||||
memset(CurrentApplication->Next, 0, sizeof(struct Application));
|
||||
CurrentApplication = CurrentApplication->Next;
|
||||
}
|
||||
else
|
||||
{
|
||||
Current->Apps = malloc(sizeof(struct Application));
|
||||
memset(Current->Apps, 0, sizeof(struct Application));
|
||||
CurrentApplication = Current->Apps;
|
||||
}
|
||||
|
||||
for (i=0; arg[i]; i+=2)
|
||||
{
|
||||
if(!strcmp(arg[i], "name"))
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentApplication->Name, 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CurrentApplication)
|
||||
{
|
||||
if (!strcmp(tag, "installscript")) {
|
||||
InstallScriptOpen = TRUE;
|
||||
} else if (!strcmp(tag, "uninstallscript")) {
|
||||
UninstallScriptOpen = TRUE;
|
||||
} else {
|
||||
Script_tag_opened(usrdata, tag, arg);
|
||||
if (CurrentScript == NULL) {
|
||||
strncpy(CurrentTag, tag, 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||
}
|
||||
|
||||
|
||||
void text (void* usrdata, const char* data, int len)
|
||||
{
|
||||
if (!CurrentApplication)
|
||||
return;
|
||||
|
||||
if(!strcmp(CurrentTag, "maintainer"))
|
||||
{
|
||||
int currentlengt = lstrlenW(CurrentApplication->Maintainer);
|
||||
MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Maintainer[currentlengt], 0x100-currentlengt);
|
||||
}
|
||||
else if(!strcmp(CurrentTag, "regname"))
|
||||
{
|
||||
int currentlengt = lstrlenW(CurrentApplication->RegName);
|
||||
MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->RegName[currentlengt], 0x100-currentlengt);
|
||||
}
|
||||
else if(!strcmp(CurrentTag, "description"))
|
||||
{
|
||||
int currentlengt = lstrlenW(CurrentApplication->Description);
|
||||
MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Description[currentlengt], 0x400-currentlengt);
|
||||
}
|
||||
else if(!strcmp(CurrentTag, "location"))
|
||||
{
|
||||
int currentlengt = lstrlenW(CurrentApplication->Location);
|
||||
MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Location[currentlengt], 0x100-currentlengt);
|
||||
}
|
||||
else if(!strcmp(CurrentTag, "version"))
|
||||
{
|
||||
int currentlengt = lstrlenW(CurrentApplication->Version);
|
||||
MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Version[currentlengt], 0x400-currentlengt);
|
||||
}
|
||||
else if(!strcmp(CurrentTag, "licence"))
|
||||
{
|
||||
int currentlengt = lstrlenW(CurrentApplication->Licence);
|
||||
MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Licence[currentlengt], 0x100-currentlengt);
|
||||
}
|
||||
}
|
||||
|
||||
void tag_closed (void* tree, const char* tag)
|
||||
{
|
||||
CurrentTag[0] = 0;
|
||||
|
||||
if(!strcmp(tag, "category"))
|
||||
{
|
||||
if (TagOpen)
|
||||
{
|
||||
TagOpen = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Current = Current->Parent;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(tag, "application"))
|
||||
{
|
||||
CurrentApplication = NULL;
|
||||
}
|
||||
else if(!strcmp(tag, "installscript") || !strcmp(tag, "uninstallscript"))
|
||||
{
|
||||
CurrentScript = NULL;
|
||||
InstallScriptOpen = FALSE;
|
||||
UninstallScriptOpen = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL ImportXML (const char* filename)
|
||||
{
|
||||
int done = 0;
|
||||
char buffer[0x100];
|
||||
FILE* file;
|
||||
XML_Parser parser;
|
||||
strcpy(buffer, Path);
|
||||
strncat(buffer, filename, 0x100-strlen(buffer));
|
||||
file = fopen(buffer, "r");
|
||||
if(!file)
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
parser = XML_ParserCreate(NULL);
|
||||
XML_SetElementHandler(parser, tag_opened, tag_closed);
|
||||
XML_SetCharacterDataHandler(parser, text);
|
||||
|
||||
while (!done)
|
||||
{
|
||||
size_t len = fread (buffer, 1, sizeof(buffer), file);
|
||||
done = len < sizeof(buffer);
|
||||
|
||||
buffer[len] = 0;
|
||||
if(!XML_Parse(parser, buffer, len, done))
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XML_ParserFree(parser);
|
||||
fclose(file);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ProcessXML (const char* filename, struct Category* Root)
|
||||
{
|
||||
FILE* file;
|
||||
file = fopen(filename, "r");
|
||||
if(file)
|
||||
{
|
||||
Path[0]='\0';
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(Path, getenv("SystemRoot"), 0x100-13);
|
||||
strcat(Path, "\\packagetree\\");
|
||||
}
|
||||
|
||||
if(Current)
|
||||
return FALSE;
|
||||
|
||||
Current = Root;
|
||||
CurrentApplication = NULL;
|
||||
CurrentScript = NULL;
|
||||
TagOpen = TRUE;
|
||||
InstallScriptOpen = FALSE;
|
||||
UninstallScriptOpen = FALSE;
|
||||
|
||||
return ImportXML(filename);
|
||||
}
|
||||
|
||||
void DML_tag_opened (void* usrdata, const char* tag, const char** arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!strcmp(tag, "application"))
|
||||
{
|
||||
for (i=0; arg[i]; i+=2)
|
||||
{
|
||||
if(!strcmp(arg[i], "name"))
|
||||
{
|
||||
strncpy(DML_Name, arg[i+1], 0x100);
|
||||
}
|
||||
else if(!strcmp(arg[i], "target"))
|
||||
{
|
||||
strncpy(DML_Target, arg[i+1], 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NOP_text (void* usrdata, const char* data, int len)
|
||||
{
|
||||
}
|
||||
|
||||
void NOP_tag_closed (void* tree, const char* tag)
|
||||
{
|
||||
}
|
||||
|
||||
char* addDML (const char* filename)
|
||||
{
|
||||
int done = 0;
|
||||
char buffer[0x100];
|
||||
FILE* file;
|
||||
XML_Parser parser;
|
||||
DML_Target[0] = '\0';
|
||||
file = fopen(filename, "r");
|
||||
if(!file)
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
parser = XML_ParserCreate(NULL);
|
||||
XML_SetElementHandler(parser, DML_tag_opened, NOP_tag_closed);
|
||||
XML_SetCharacterDataHandler(parser, NOP_text);
|
||||
|
||||
while (!done)
|
||||
{
|
||||
size_t len = fread (buffer, 1, sizeof(buffer), file);
|
||||
done = len < sizeof(buffer);
|
||||
|
||||
buffer[len] = 0;
|
||||
if(!XML_Parse(parser, buffer, len, done))
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
XML_ParserFree(parser);
|
||||
fclose(file);
|
||||
|
||||
if(DML_Target[0]=='\0')
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(buffer, getenv("SystemRoot"));
|
||||
strncat(buffer, "\\packagetree\\", 0x100-strlen(buffer));
|
||||
strncat(buffer, DML_Target, 0x100-strlen(buffer));
|
||||
|
||||
CopyFileA(filename, buffer, FALSE);
|
||||
return DML_Name;
|
||||
}
|
||||
|
||||
void LoadScriptFunc(WCHAR* filenameW, struct ScriptElement* Script)
|
||||
{
|
||||
int done = 0;
|
||||
char buffer[0x100];
|
||||
char filenameA[0x100];
|
||||
FILE* file;
|
||||
XML_Parser parser;
|
||||
struct ScriptElement* NextElement = Script->Next;
|
||||
wcscpy(Script->Func,L"NOP");
|
||||
CurrentScript = Script;
|
||||
WideCharToMultiByte(CP_UTF8, 0, filenameW, -1, filenameA, 0x100, NULL, FALSE);
|
||||
strcpy(buffer, Path);
|
||||
strncat(buffer, filenameA, 0x100-strlen(buffer));
|
||||
file = fopen(buffer, "r");
|
||||
if(!file)
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
|
||||
return;
|
||||
}
|
||||
|
||||
parser = XML_ParserCreate(NULL);
|
||||
XML_SetElementHandler(parser, Script_tag_opened, NOP_tag_closed);
|
||||
XML_SetCharacterDataHandler(parser, NOP_text);
|
||||
|
||||
while (!done)
|
||||
{
|
||||
size_t len = fread (buffer, 1, sizeof(buffer), file);
|
||||
done = len < sizeof(buffer);
|
||||
|
||||
buffer[len] = 0;
|
||||
if(!XML_Parse(parser, buffer, len, done))
|
||||
{
|
||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||
CurrentScript->Next = NextElement;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XML_ParserFree(parser);
|
||||
fclose(file);
|
||||
CurrentScript->Next = NextElement;
|
||||
return;
|
||||
}
|
||||
|
||||
void FreeScript (struct ScriptElement* Script)
|
||||
{
|
||||
if (Script->Next != NULL)
|
||||
FreeScript(Script->Next);
|
||||
free(Script);
|
||||
}
|
||||
|
||||
void FreeApps (struct Application* Apps)
|
||||
{
|
||||
if (Apps->Next)
|
||||
FreeApps(Apps->Next);
|
||||
if (Apps->InstallScript)
|
||||
FreeScript(Apps->InstallScript);
|
||||
if (Apps->UninstallScript)
|
||||
FreeScript(Apps->UninstallScript);
|
||||
|
||||
free(Apps);
|
||||
}
|
||||
|
||||
void FreeTree (struct Category* Node)
|
||||
{
|
||||
if (Node->Children)
|
||||
FreeTree(Node->Children);
|
||||
|
||||
if (Node->Next)
|
||||
FreeTree(Node->Next);
|
||||
|
||||
if (Node->Apps)
|
||||
FreeApps(Node->Apps);
|
||||
|
||||
free(Node);
|
||||
}
|
136
rosapps/ext2/attr.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/attr.c
|
||||
* PURPOSE: Set/Get file attributes support
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2SetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DPRINT("Ext2SetInformation(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp,
|
||||
IO_NO_INCREMENT);
|
||||
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2QueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PIO_STACK_LOCATION Param;
|
||||
PFILE_OBJECT FileObject;
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
ULONG Length;
|
||||
PFILE_BASIC_INFORMATION PFileBasicInformation;
|
||||
PFILE_STANDARD_INFORMATION PFileStandardInformation;
|
||||
PFILE_INTERNAL_INFORMATION PFileInternalInformation;
|
||||
PFILE_EA_INFORMATION PFileEaInformation;
|
||||
PFILE_ACCESS_INFORMATION PFileAccessInformation;
|
||||
PFILE_NAME_INFORMATION PFileNameInformation;
|
||||
PFILE_POSITION_INFORMATION PFilePositionInformation;
|
||||
PVOID Buffer;
|
||||
|
||||
DPRINT("Ext2QueryInformation(DeviceObject %x Irp %x)\n", DeviceObject, Irp);
|
||||
|
||||
Param = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileObject = Param->FileObject;
|
||||
DeviceExt = DeviceObject->DeviceExtension;
|
||||
Length = Param->Parameters.QueryFile.Length;
|
||||
Buffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
switch (Param->Parameters.QueryFile.FileInformationClass)
|
||||
{
|
||||
case FileDirectoryInformation:
|
||||
case FileFullDirectoryInformation:
|
||||
case FileBothDirectoryInformation:
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
break;
|
||||
|
||||
case FileBasicInformation:
|
||||
PFileBasicInformation = (PFILE_BASIC_INFORMATION)Buffer;
|
||||
memset(PFileBasicInformation, 0, sizeof(FILE_BASIC_INFORMATION));
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FileStandardInformation:
|
||||
PFileStandardInformation = (PFILE_STANDARD_INFORMATION)Buffer;
|
||||
memset(PFileStandardInformation, 0, sizeof(FILE_STANDARD_INFORMATION));
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FileInternalInformation:
|
||||
PFileInternalInformation = (PFILE_INTERNAL_INFORMATION)Buffer;
|
||||
memset(PFileInternalInformation, 0, sizeof(FILE_INTERNAL_INFORMATION));
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FileEaInformation:
|
||||
PFileEaInformation = (PFILE_EA_INFORMATION)Buffer;
|
||||
memset(PFileEaInformation, 0, sizeof(FILE_EA_INFORMATION));
|
||||
PFileEaInformation->EaSize = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FileAccessInformation:
|
||||
PFileAccessInformation = (PFILE_ACCESS_INFORMATION)Buffer;
|
||||
memset(PFileAccessInformation, 0, sizeof(FILE_ACCESS_INFORMATION));
|
||||
PFileAccessInformation->AccessFlags = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FileNameInformation:
|
||||
PFileNameInformation = (PFILE_NAME_INFORMATION)Buffer;
|
||||
memset(PFileNameInformation, 0, sizeof(FILE_NAME_INFORMATION));
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FilePositionInformation:
|
||||
PFilePositionInformation = (PFILE_POSITION_INFORMATION)Buffer;
|
||||
memcpy(PFilePositionInformation,
|
||||
&FileObject->CurrentByteOffset,
|
||||
sizeof(FileObject->CurrentByteOffset));
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case FileRenameInformation:
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
Irp->IoStatus.Information =
|
||||
Param->Parameters.QueryFile.Length - Length;
|
||||
else
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp,
|
||||
IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
}
|
155
rosapps/ext2/blockdev.c
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/blockdev.c
|
||||
* PURPOSE: Temporary sector reading support
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
Ext2ReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN PVOID Buffer)
|
||||
{
|
||||
LARGE_INTEGER sectorNumber;
|
||||
PIRP irp;
|
||||
IO_STATUS_BLOCK ioStatus;
|
||||
KEVENT event;
|
||||
NTSTATUS status;
|
||||
ULONG sectorSize;
|
||||
int j;
|
||||
|
||||
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
pDeviceObject,DiskSector,Buffer);
|
||||
|
||||
sectorNumber.u.HighPart = 0;
|
||||
sectorNumber.u.LowPart = DiskSector * BLOCKSIZE;
|
||||
|
||||
DPRINT("DiskSector:%ld BLKSZ:%ld sectorNumber:%ld:%ld\n",
|
||||
(unsigned long) DiskSector,
|
||||
(unsigned long) BLOCKSIZE,
|
||||
(unsigned long) sectorNumber.u.HighPart,
|
||||
(unsigned long) sectorNumber.u.LowPart);
|
||||
|
||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||
|
||||
sectorSize = BLOCKSIZE*SectorCount;
|
||||
|
||||
|
||||
DPRINT("Building synchronous FSD Request...\n");
|
||||
irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||
pDeviceObject,
|
||||
Buffer,
|
||||
sectorSize,
|
||||
§orNumber,
|
||||
&event,
|
||||
&ioStatus );
|
||||
|
||||
if (!irp)
|
||||
{
|
||||
DbgPrint("READ failed!!!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT("Calling IO Driver...\n");
|
||||
status = IoCallDriver(pDeviceObject, irp);
|
||||
|
||||
DPRINT("Waiting for IO Operation...\n");
|
||||
if (status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&event,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
DPRINT("Getting IO Status...\n");
|
||||
status = ioStatus.Status;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
DbgPrint("IO failed!!! Error code: %d(%x)\n", status, status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN UCHAR* Buffer)
|
||||
{
|
||||
LARGE_INTEGER sectorNumber;
|
||||
PIRP irp;
|
||||
IO_STATUS_BLOCK ioStatus;
|
||||
KEVENT event;
|
||||
NTSTATUS status;
|
||||
ULONG sectorSize;
|
||||
PULONG mbr;
|
||||
int j;
|
||||
|
||||
DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
pDeviceObject,DiskSector,Buffer);
|
||||
|
||||
sectorNumber.u.HighPart = 0;
|
||||
sectorNumber.u.LowPart = DiskSector * BLOCKSIZE;
|
||||
|
||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||
|
||||
sectorSize = BLOCKSIZE*SectorCount;
|
||||
|
||||
|
||||
DPRINT("Building synchronous FSD Request...\n");
|
||||
irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
|
||||
pDeviceObject,
|
||||
Buffer,
|
||||
sectorSize,
|
||||
§orNumber,
|
||||
&event,
|
||||
&ioStatus );
|
||||
|
||||
if (!irp) {
|
||||
DbgPrint("WRITE failed!!!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT("Calling IO Driver...\n");
|
||||
status = IoCallDriver(pDeviceObject,
|
||||
irp);
|
||||
|
||||
DPRINT("Waiting for IO Operation...\n");
|
||||
if (status == STATUS_PENDING) {
|
||||
KeWaitForSingleObject(&event,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
DPRINT("Getting IO Status...\n");
|
||||
status = ioStatus.Status;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
DbgPrint("IO failed!!! Error code: %d(%x)\n", status, status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
ExFreePool(mbr);
|
||||
DPRINT("Block request succeeded\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
338
rosapps/ext2/dir.c
Normal file
|
@ -0,0 +1,338 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/dir.c
|
||||
* PURPOSE: ext2 filesystem
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
||||
static VOID Ext2ConvertName(PWSTR Out, PCH In, ULONG Len)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for (i=0; i<Len; i++)
|
||||
{
|
||||
*Out = *In;
|
||||
Out++;
|
||||
In++;
|
||||
}
|
||||
*Out = 0;
|
||||
}
|
||||
|
||||
PVOID Ext2ProcessDirEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
struct ext2_dir_entry* dir_entry,
|
||||
PIO_STACK_LOCATION IoStack,
|
||||
PVOID Buffer,
|
||||
ULONG FileIndex)
|
||||
{
|
||||
PFILE_DIRECTORY_INFORMATION FDI;
|
||||
PFILE_NAMES_INFORMATION FNI;
|
||||
PFILE_BOTH_DIRECTORY_INFORMATION FBI;
|
||||
struct ext2_inode inode;
|
||||
|
||||
DPRINT("FileIndex %d\n",FileIndex);
|
||||
DPRINT("Buffer %x\n",Buffer);
|
||||
|
||||
Ext2ReadInode(DeviceExt,
|
||||
dir_entry->inode,
|
||||
&inode);
|
||||
|
||||
switch (IoStack->Parameters.QueryDirectory.FileInformationClass)
|
||||
{
|
||||
case FileNamesInformation:
|
||||
FNI = (PFILE_NAMES_INFORMATION)Buffer;
|
||||
FNI->NextEntryOffset = sizeof(FileDirectoryInformation) +
|
||||
dir_entry->name_len + 1;
|
||||
FNI->FileNameLength = dir_entry->name_len;
|
||||
Ext2ConvertName(FNI->FileName, dir_entry->name, dir_entry->name_len);
|
||||
Buffer = Buffer + FNI->NextEntryOffset;
|
||||
break;
|
||||
|
||||
case FileDirectoryInformation:
|
||||
FDI = (PFILE_DIRECTORY_INFORMATION)Buffer;
|
||||
FDI->NextEntryOffset = sizeof(FileDirectoryInformation) +
|
||||
dir_entry->name_len + 1;
|
||||
FDI->FileIndex = FileIndex;
|
||||
// FDI->CreationTime = 0;
|
||||
// FDI->LastAccessTime = 0;
|
||||
// FDI->LastWriteTime = 0;
|
||||
// FDI->ChangeTime = 0;
|
||||
FDI->AllocationSize.QuadPart = FDI->EndOfFile.QuadPart = inode.i_size;
|
||||
FDI->FileAttributes = 0;
|
||||
FDI->FileNameLength = dir_entry->name_len;
|
||||
Ext2ConvertName(FDI->FileName, dir_entry->name, dir_entry->name_len);
|
||||
Buffer = Buffer + FDI->NextEntryOffset;
|
||||
break;
|
||||
|
||||
case FileBothDirectoryInformation:
|
||||
FBI = (PFILE_BOTH_DIRECTORY_INFORMATION)Buffer;
|
||||
FBI->NextEntryOffset = sizeof(FileBothDirectoryInformation) +
|
||||
dir_entry->name_len + 1;
|
||||
FBI->FileIndex = FileIndex;
|
||||
FBI->AllocationSize.QuadPart = FBI->EndOfFile.QuadPart = inode.i_size;
|
||||
FBI->FileAttributes = 0;
|
||||
FBI->FileNameLength = dir_entry->name_len;
|
||||
Ext2ConvertName(FBI->FileName, dir_entry->name, dir_entry->name_len);
|
||||
memset(FBI->ShortName, 0, sizeof(FBI->ShortName));
|
||||
Buffer = Buffer + FBI->NextEntryOffset;
|
||||
break;
|
||||
|
||||
default:
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
return(Buffer);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS Ext2QueryDirectory(PDEVICE_EXTENSION DeviceExt,
|
||||
PEXT2_FCB Fcb,
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IoStack)
|
||||
{
|
||||
ULONG Max;
|
||||
ULONG i;
|
||||
ULONG StartIndex;
|
||||
PVOID Buffer = NULL;
|
||||
struct ext2_dir_entry dir_entry;
|
||||
|
||||
Buffer = Irp->UserBuffer;
|
||||
DPRINT("Buffer %x\n",Buffer);
|
||||
DPRINT("IoStack->Flags %x\n",IoStack->Flags);
|
||||
|
||||
if (IoStack->Flags & SL_RETURN_SINGLE_ENTRY)
|
||||
{
|
||||
Max = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
DPRINT("Buffer->FileIndex %d\n",
|
||||
((PFILE_DIRECTORY_INFORMATION)Buffer)->FileIndex);
|
||||
if (IoStack->Flags & SL_INDEX_SPECIFIED)
|
||||
{
|
||||
StartIndex = ((PFILE_DIRECTORY_INFORMATION)Buffer)->FileIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIndex = 0;
|
||||
}
|
||||
|
||||
if (IoStack->Flags & SL_RESTART_SCAN)
|
||||
{
|
||||
StartIndex = 0;
|
||||
}
|
||||
|
||||
DPRINT("StartIndex %d\n",StartIndex);
|
||||
|
||||
for (i=0; i<Max ;i++)
|
||||
{
|
||||
if (!Ext2ScanDir(DeviceExt,&Fcb->inode,"*",&dir_entry,&StartIndex))
|
||||
{
|
||||
((PFILE_DIRECTORY_INFORMATION)Buffer)->NextEntryOffset = 0;
|
||||
return(STATUS_NO_MORE_FILES);
|
||||
}
|
||||
Buffer = Ext2ProcessDirEntry(DeviceExt,
|
||||
&dir_entry,
|
||||
IoStack,
|
||||
Buffer,
|
||||
StartIndex);
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2DirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
||||
PEXT2_FCB Fcb = (PVOID)FileObject->FsContext;
|
||||
NTSTATUS Status;
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
|
||||
DPRINT("Ext2DirectoryControl(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
DeviceExt = DeviceObject->DeviceExtension;
|
||||
|
||||
switch (Stack->MinorFunction)
|
||||
{
|
||||
case IRP_MN_QUERY_DIRECTORY:
|
||||
Status = Ext2QueryDirectory(DeviceExt, Fcb, Irp, Stack);
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
BOOL Ext2ScanDir(PDEVICE_EXTENSION DeviceExt,
|
||||
struct ext2_inode* dir,
|
||||
PCH filename,
|
||||
struct ext2_dir_entry* ret,
|
||||
PULONG StartIndex)
|
||||
{
|
||||
ULONG i;
|
||||
char* buffer;
|
||||
ULONG offset;
|
||||
char name[255];
|
||||
struct ext2_dir_entry* current;
|
||||
ULONG block;
|
||||
BOOL b;
|
||||
|
||||
DPRINT("Ext2ScanDir(dir %x, filename %s, ret %x)\n",dir,filename,ret);
|
||||
|
||||
buffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
|
||||
|
||||
for (i=0; i<((*StartIndex)/BLOCKSIZE); i++);
|
||||
for (; (block = Ext2BlockMap(DeviceExt, dir, i)) != 0; i++)
|
||||
{
|
||||
DPRINT("block %d\n",block);
|
||||
b = Ext2ReadSectors(DeviceExt->StorageDevice,
|
||||
block,
|
||||
1,
|
||||
buffer);
|
||||
if (!b)
|
||||
{
|
||||
DbgPrint("ext2fs:%s:%d: Disk io failed\n", __FILE__, __LINE__);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
offset = (*StartIndex)%BLOCKSIZE;
|
||||
while (offset < BLOCKSIZE)
|
||||
{
|
||||
current = &buffer[offset];
|
||||
|
||||
strncpy(name,current->name,current->name_len);
|
||||
name[current->name_len]=0;
|
||||
|
||||
DPRINT("Scanning offset %d inode %d name %s\n",
|
||||
offset,current->inode,name);
|
||||
|
||||
DPRINT("Comparing %s %s\n",name,filename);
|
||||
if (strcmp(name,filename)==0 || strcmp(filename,"*")==0)
|
||||
{
|
||||
DPRINT("Match found\n");
|
||||
*StartIndex = (i*BLOCKSIZE) + offset + current->rec_len;
|
||||
memcpy(ret,current,sizeof(struct ext2_dir_entry));
|
||||
ExFreePool(buffer);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
offset = offset + current->rec_len;
|
||||
ASSERT(current->rec_len != 0);
|
||||
DPRINT("offset %d\n",offset);
|
||||
}
|
||||
DPRINT("Onto next block\n");
|
||||
}
|
||||
DPRINT("No match\n");
|
||||
ExFreePool(buffer);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
void unicode_to_ansi(PCH StringA, PWSTR StringW)
|
||||
{
|
||||
while((*StringW)!=0)
|
||||
{
|
||||
*StringA = *StringW;
|
||||
StringA++;
|
||||
StringW++;
|
||||
}
|
||||
*StringA = 0;
|
||||
}
|
||||
|
||||
NTSTATUS Ext2OpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PWSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Opens a file
|
||||
*/
|
||||
{
|
||||
EXT2_INODE parent_inode;
|
||||
struct ext2_dir_entry entry;
|
||||
char name[255];
|
||||
ULONG current_inode = 2;
|
||||
char* current_segment;
|
||||
PEXT2_FCB Fcb;
|
||||
ULONG StartIndex = 0;
|
||||
|
||||
DPRINT("Ext2OpenFile(DeviceExt %x, FileObject %x, FileName %S)\n",
|
||||
DeviceExt,FileObject,FileName);
|
||||
|
||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(EXT2_FCB));
|
||||
|
||||
unicode_to_ansi(name,FileName);
|
||||
DPRINT("name %s\n",name);
|
||||
DPRINT("strtok %x\n",strtok);
|
||||
current_segment = strtok(name,"\\");
|
||||
DPRINT("current_segment %x\n", current_segment);
|
||||
while (current_segment!=NULL)
|
||||
{
|
||||
Ext2LoadInode(DeviceExt,
|
||||
current_inode,
|
||||
&parent_inode);
|
||||
if (!Ext2ScanDir(DeviceExt,
|
||||
parent_inode.inode,
|
||||
current_segment,
|
||||
&entry,
|
||||
&StartIndex))
|
||||
{
|
||||
Ext2ReleaseInode(DeviceExt,
|
||||
&parent_inode);
|
||||
ExFreePool(Fcb);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
current_inode = entry.inode;
|
||||
current_segment = strtok(NULL,"\\");
|
||||
StartIndex = 0;
|
||||
Ext2ReleaseInode(DeviceExt,
|
||||
&parent_inode);
|
||||
}
|
||||
DPRINT("Found file\n");
|
||||
|
||||
Fcb->inode = current_inode;
|
||||
CcRosInitializeFileCache(FileObject, &Fcb->Bcb, PAGE_SIZE*3);
|
||||
FileObject->FsContext = Fcb;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2Create(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
||||
NTSTATUS Status;
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
|
||||
DPRINT("Ext2Create(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
DeviceExt = DeviceObject->DeviceExtension;
|
||||
Status = Ext2OpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
289
rosapps/ext2/ext2fs.h
Normal file
|
@ -0,0 +1,289 @@
|
|||
#include <ntddk.h>
|
||||
#include <ntifs.h>
|
||||
|
||||
BOOLEAN Ext2ReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN PVOID Buffer);
|
||||
|
||||
#define BLOCKSIZE (1024)
|
||||
|
||||
struct ext2_super_block {
|
||||
ULONG s_inodes_count; /* Inodes count */
|
||||
ULONG s_blocks_count; /* Blocks count */
|
||||
ULONG s_r_blocks_count; /* Reserved blocks count */
|
||||
ULONG s_free_blocks_count; /* Free blocks count */
|
||||
ULONG s_free_inodes_count; /* Free inodes count */
|
||||
ULONG s_first_data_block; /* First Data Block */
|
||||
ULONG s_log_block_size; /* Block size */
|
||||
LONG s_log_frag_size; /* Fragment size */
|
||||
ULONG s_blocks_per_group; /* # Blocks per group */
|
||||
ULONG s_frags_per_group; /* # Fragments per group */
|
||||
ULONG s_inodes_per_group; /* # Inodes per group */
|
||||
ULONG s_mtime; /* Mount time */
|
||||
ULONG s_wtime; /* Write time */
|
||||
USHORT s_mnt_count; /* Mount count */
|
||||
SHORT s_max_mnt_count; /* Maximal mount count */
|
||||
USHORT s_magic; /* Magic signature */
|
||||
USHORT s_state; /* File system state */
|
||||
USHORT s_errors; /* Behaviour when detecting errors */
|
||||
USHORT s_minor_rev_level; /* minor revision level */
|
||||
ULONG s_lastcheck; /* time of last check */
|
||||
ULONG s_checkinterval; /* max. time between checks */
|
||||
ULONG s_creator_os; /* OS */
|
||||
ULONG s_rev_level; /* Revision level */
|
||||
USHORT s_def_resuid; /* Default uid for reserved blocks */
|
||||
USHORT s_def_resgid; /* Default gid for reserved blocks */
|
||||
/*
|
||||
* These fields are for EXT2_DYNAMIC_REV superblocks only.
|
||||
*
|
||||
* Note: the difference between the compatible feature set and
|
||||
* the incompatible feature set is that if there is a bit set
|
||||
* in the incompatible feature set that the kernel doesn't
|
||||
* know about, it should refuse to mount the filesystem.
|
||||
*
|
||||
* e2fsck's requirements are more strict; if it doesn't know
|
||||
* about a feature in either the compatible or incompatible
|
||||
* feature set, it must abort and not try to meddle with
|
||||
* things it doesn't understand...
|
||||
*/
|
||||
ULONG s_first_ino; /* First non-reserved inode */
|
||||
USHORT s_inode_size; /* size of inode structure */
|
||||
USHORT s_block_group_nr; /* block group # of this superblock */
|
||||
ULONG s_feature_compat; /* compatible feature set */
|
||||
ULONG s_feature_incompat; /* incompatible feature set */
|
||||
ULONG s_feature_ro_compat; /* readonly-compatible feature set */
|
||||
ULONG s_reserved[230]; /* Padding to the end of the block */
|
||||
};
|
||||
|
||||
/*
|
||||
* Codes for operating systems
|
||||
*/
|
||||
#define EXT2_OS_LINUX 0
|
||||
#define EXT2_OS_HURD 1
|
||||
#define EXT2_OS_MASIX 2
|
||||
#define EXT2_OS_FREEBSD 3
|
||||
#define EXT2_OS_LITES 4
|
||||
|
||||
/*
|
||||
* Revision levels
|
||||
*/
|
||||
#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
|
||||
#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
|
||||
|
||||
#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
|
||||
#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
|
||||
|
||||
/*
|
||||
* The second extended file system magic number
|
||||
*/
|
||||
#define EXT2_SUPER_MAGIC 0xEF53
|
||||
|
||||
/*
|
||||
* Constants relative to the data blocks
|
||||
*/
|
||||
#define EXT2_NDIR_BLOCKS 12
|
||||
#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
|
||||
#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
|
||||
#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
|
||||
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
|
||||
|
||||
|
||||
/*
|
||||
* Structure of an inode on the disk
|
||||
*/
|
||||
struct ext2_inode {
|
||||
USHORT i_mode; /* File mode */
|
||||
USHORT i_uid; /* Owner Uid */
|
||||
ULONG i_size; /* Size in bytes */
|
||||
ULONG i_atime; /* Access time */
|
||||
ULONG i_ctime; /* Creation time */
|
||||
ULONG i_mtime; /* Modification time */
|
||||
ULONG i_dtime; /* Deletion Time */
|
||||
USHORT i_gid; /* Group Id */
|
||||
USHORT i_links_count; /* Links count */
|
||||
ULONG i_blocks; /* Blocks count */
|
||||
ULONG i_flags; /* File flags */
|
||||
union {
|
||||
struct {
|
||||
ULONG l_i_reserved1;
|
||||
} linux1;
|
||||
struct {
|
||||
ULONG h_i_translator;
|
||||
} hurd1;
|
||||
struct {
|
||||
ULONG m_i_reserved1;
|
||||
} masix1;
|
||||
} osd1; /* OS dependent 1 */
|
||||
ULONG i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
|
||||
ULONG i_version; /* File version (for NFS) */
|
||||
ULONG i_file_acl; /* File ACL */
|
||||
ULONG i_dir_acl; /* Directory ACL */
|
||||
ULONG i_faddr; /* Fragment address */
|
||||
union {
|
||||
struct {
|
||||
UCHAR l_i_frag; /* Fragment number */
|
||||
UCHAR l_i_fsize; /* Fragment size */
|
||||
USHORT i_pad1;
|
||||
ULONG l_i_reserved2[2];
|
||||
} linux2;
|
||||
struct {
|
||||
UCHAR h_i_frag; /* Fragment number */
|
||||
UCHAR h_i_fsize; /* Fragment size */
|
||||
USHORT h_i_mode_high;
|
||||
USHORT h_i_uid_high;
|
||||
USHORT h_i_gid_high;
|
||||
ULONG h_i_author;
|
||||
} hurd2;
|
||||
struct {
|
||||
UCHAR m_i_frag; /* Fragment number */
|
||||
UCHAR m_i_fsize; /* Fragment size */
|
||||
USHORT m_pad1;
|
||||
ULONG m_i_reserved2[2];
|
||||
} masix2;
|
||||
} osd2; /* OS dependent 2 */
|
||||
};
|
||||
|
||||
#if defined(__KERNEL__) || defined(__linux__)
|
||||
#define i_reserved1 osd1.linux1.l_i_reserved1
|
||||
#define i_frag osd2.linux2.l_i_frag
|
||||
#define i_fsize osd2.linux2.l_i_fsize
|
||||
#define i_reserved2 osd2.linux2.l_i_reserved2
|
||||
#endif
|
||||
|
||||
#ifdef __hurd__
|
||||
#define i_translator osd1.hurd1.h_i_translator
|
||||
#define i_frag osd2.hurd2.h_i_frag;
|
||||
#define i_fsize osd2.hurd2.h_i_fsize;
|
||||
#define i_uid_high osd2.hurd2.h_i_uid_high
|
||||
#define i_gid_high osd2.hurd2.h_i_gid_high
|
||||
#define i_author osd2.hurd2.h_i_author
|
||||
#endif
|
||||
|
||||
#ifdef __masix__
|
||||
#define i_reserved1 osd1.masix1.m_i_reserved1
|
||||
#define i_frag osd2.masix2.m_i_frag
|
||||
#define i_fsize osd2.masix2.m_i_fsize
|
||||
#define i_reserved2 osd2.masix2.m_i_reserved2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants relative to the data blocks
|
||||
*/
|
||||
#define EXT2_NDIR_BLOCKS 12
|
||||
#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
|
||||
#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
|
||||
#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
|
||||
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
|
||||
|
||||
/*
|
||||
* Inode flags
|
||||
*/
|
||||
#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
|
||||
#define EXT2_UNRM_FL 0x00000002 /* Undelete */
|
||||
#define EXT2_COMPR_FL 0x00000004 /* Compress file */
|
||||
#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
|
||||
#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
|
||||
#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
|
||||
#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
|
||||
#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
|
||||
|
||||
|
||||
/*
|
||||
* Structure of a blocks group descriptor
|
||||
*/
|
||||
struct ext2_group_desc
|
||||
{
|
||||
ULONG bg_block_bitmap; /* Blocks bitmap block */
|
||||
ULONG bg_inode_bitmap; /* Inodes bitmap block */
|
||||
ULONG bg_inode_table; /* Inodes table block */
|
||||
USHORT bg_free_blocks_count; /* Free blocks count */
|
||||
USHORT bg_free_inodes_count; /* Free inodes count */
|
||||
USHORT bg_used_dirs_count; /* Directories count */
|
||||
USHORT bg_pad;
|
||||
ULONG bg_reserved[3];
|
||||
};
|
||||
|
||||
#define EXT2_NAME_LEN 255
|
||||
|
||||
struct ext2_dir_entry {
|
||||
ULONG inode; /* Inode number */
|
||||
USHORT rec_len; /* Directory entry length */
|
||||
USHORT name_len; /* Name length */
|
||||
char name[EXT2_NAME_LEN]; /* File name */
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PDEVICE_OBJECT StorageDevice;
|
||||
struct ext2_super_block* superblock;
|
||||
PFILE_OBJECT FileObject;
|
||||
PBCB Bcb;
|
||||
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||
|
||||
typedef struct _EXT2_GROUP_DESC
|
||||
{
|
||||
ERESOURCE Lock;
|
||||
struct ext2_group_desc* desc;
|
||||
PCACHE_SEGMENT CacheSeg;
|
||||
PVOID BaseAddress;
|
||||
} EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
|
||||
|
||||
PEXT2_GROUP_DESC Ext2LoadGroup(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG BlockGrp);
|
||||
VOID Ext2ReleaseGroup(PDEVICE_EXTENSION DeviceExt,
|
||||
PEXT2_GROUP_DESC GrpDesc);
|
||||
|
||||
VOID Ext2ReadInode(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG ino,
|
||||
struct ext2_inode* inode);
|
||||
struct ext2_group_desc* Ext2LoadGroupDesc(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG block_group);
|
||||
|
||||
typedef struct _EXT2_INODE
|
||||
{
|
||||
struct ext2_inode* inode;
|
||||
PVOID BaseAddress;
|
||||
PCACHE_SEGMENT CacheSeg;
|
||||
} EXT2_INODE, *PEXT2_INODE;
|
||||
|
||||
typedef struct _EXT2_FCB
|
||||
{
|
||||
ULONG inode;
|
||||
EXT2_INODE i;
|
||||
PBCB Bcb;
|
||||
} EXT2_FCB, *PEXT2_FCB;
|
||||
|
||||
ULONG Ext2BlockMap(PDEVICE_EXTENSION DeviceExt,
|
||||
struct ext2_inode* inode,
|
||||
ULONG offset);
|
||||
NTSTATUS Ext2OpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PWSTR FileName);
|
||||
NTSTATUS Ext2ReadFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT FileObject,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
LARGE_INTEGER Offset);
|
||||
NTSTATUS STDCALL Ext2Create(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2DirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2QueryQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2SetQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2SetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2QuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2SetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2QueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2Read(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2Write(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2Cleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2FlushBuffers(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL Ext2Shutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS Ext2ReadPage(PDEVICE_EXTENSION DeviceExt,
|
||||
PEXT2_FCB Fcb,
|
||||
PVOID Buffer,
|
||||
ULONG Offset);
|
||||
VOID Ext2LoadInode(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG ino,
|
||||
PEXT2_INODE Inode);
|
||||
VOID Ext2ReleaseInode(PDEVICE_EXTENSION DeviceExt,
|
||||
PEXT2_INODE Inode);
|
||||
|
7
rosapps/ext2/ext2fs.rc
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$ */
|
||||
|
||||
#define REACTOS_VERSION_DLL
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Linux ext2 IFS Driver\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "ext2fs\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "ext2fs.sys\0"
|
||||
#include <reactos/version.rc>
|
61
rosapps/ext2/file.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/super.c
|
||||
* PURPOSE: ext2 filesystem
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#define addr_per_block (BLOCKSIZE / sizeof(ULONG))
|
||||
|
||||
ULONG Ext2BlockMap(PDEVICE_EXTENSION DeviceExt,
|
||||
struct ext2_inode* inode,
|
||||
ULONG offset)
|
||||
{
|
||||
ULONG block;
|
||||
PULONG TempBuffer;
|
||||
BOOL b;
|
||||
|
||||
DPRINT("Ext2BlockMap(DeviceExt %x, inode %x, offset %d)\n",
|
||||
DeviceExt,inode,offset);
|
||||
if (offset < EXT2_NDIR_BLOCKS)
|
||||
{
|
||||
block = inode->i_block[offset];
|
||||
DPRINT("block %d\n",block);
|
||||
return(block);
|
||||
}
|
||||
offset = offset - EXT2_NDIR_BLOCKS;
|
||||
if (offset < addr_per_block)
|
||||
{
|
||||
block = inode->i_block[EXT2_IND_BLOCK];
|
||||
TempBuffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
|
||||
b = Ext2ReadSectors(DeviceExt->StorageDevice,
|
||||
block,
|
||||
1,
|
||||
TempBuffer);
|
||||
if (!b)
|
||||
{
|
||||
DbgPrint("ext2fs:%s:%d: Disk io failed\n", __FILE__, __LINE__);
|
||||
return(0);
|
||||
}
|
||||
block = TempBuffer[offset];
|
||||
ExFreePool(TempBuffer);
|
||||
return(block);
|
||||
}
|
||||
offset = offset - addr_per_block;
|
||||
DbgPrint("Failed at %s:%d\n",__FILE__,__LINE__);
|
||||
for(;;);
|
||||
}
|
||||
|
148
rosapps/ext2/inode.c
Normal file
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/inode.c
|
||||
* PURPOSE: Manipulating inodes
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* 26/12/98: Created
|
||||
*/
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
struct ext2_group_desc* Ext2LoadGroupDesc(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG block_group)
|
||||
{
|
||||
struct ext2_group_desc* buffer;
|
||||
ULONG block;
|
||||
struct ext2_group_desc* gdp;
|
||||
|
||||
buffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
|
||||
|
||||
block = block_group / (BLOCKSIZE / sizeof(struct ext2_group_desc));
|
||||
|
||||
Ext2ReadSectors(DeviceExt->StorageDevice,
|
||||
2 + block,
|
||||
1,
|
||||
buffer);
|
||||
|
||||
gdp = &buffer[block_group % (BLOCKSIZE / sizeof(struct ext2_group_desc))];
|
||||
|
||||
DPRINT("gdp->bg_free_blocks_count %d\n",gdp->bg_free_blocks_count);
|
||||
DPRINT("gdp->bg_inode_table %d\n",gdp->bg_inode_table);
|
||||
|
||||
return(gdp);
|
||||
|
||||
}
|
||||
|
||||
#define INODES_PER_PAGE (PAGE_SIZE / sizeof(struct ext2_inode))
|
||||
#define INODES_PER_BLOCK (BLOCKSIZE / sizeof(struct ext2_inode))
|
||||
|
||||
VOID Ext2LoadInode(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG ino,
|
||||
PEXT2_INODE Inode)
|
||||
{
|
||||
ULONG block_group;
|
||||
struct ext2_group_desc* gdp;
|
||||
ULONG offset;
|
||||
ULONG dsec;
|
||||
BOOLEAN Uptodate;
|
||||
struct ext2_inode* ibuffer;
|
||||
|
||||
DPRINT("Ext2LoadInode(DeviceExt %x, ino %d, Inode %x)\n",
|
||||
DeviceExt, ino, Inode);
|
||||
|
||||
block_group = (ino - 1) / DeviceExt->superblock->s_inodes_per_group;
|
||||
|
||||
DPRINT("block_group %d\n",block_group);
|
||||
|
||||
gdp = Ext2LoadGroupDesc(DeviceExt, block_group);
|
||||
|
||||
offset = (ino - 1) % DeviceExt->superblock->s_inodes_per_group;
|
||||
|
||||
DPRINT("offset %d\n", offset);
|
||||
|
||||
dsec = (gdp->bg_inode_table + (offset / INODES_PER_BLOCK)) * BLOCKSIZE;
|
||||
|
||||
DPRINT("dsec %d (dsec/BLOCKSIZE) %d PAGE_ROUND_DOWN(dsec) %d\n",
|
||||
dsec, (dsec/BLOCKSIZE), PAGE_ROUND_DOWN(dsec));
|
||||
|
||||
CcRequestCachePage(DeviceExt->Bcb,
|
||||
PAGE_ROUND_DOWN(dsec),
|
||||
&Inode->BaseAddress,
|
||||
&Uptodate,
|
||||
&Inode->CacheSeg);
|
||||
DPRINT("PAGE_ROUND_DOWN(dsec)/BLOCKSIZE %d\n",
|
||||
PAGE_ROUND_DOWN(dsec)/BLOCKSIZE);
|
||||
if (!Uptodate)
|
||||
{
|
||||
Ext2ReadSectors(DeviceExt->StorageDevice,
|
||||
PAGE_ROUND_DOWN(dsec) / BLOCKSIZE,
|
||||
4,
|
||||
Inode->BaseAddress);
|
||||
}
|
||||
ibuffer = ((struct ext2_inode *)Inode->BaseAddress) +
|
||||
(dsec - PAGE_ROUND_DOWN(dsec));
|
||||
DPRINT("Inode->BaseAddress 0x%x ibuffer 0x%x\n",
|
||||
Inode->BaseAddress, ibuffer);
|
||||
Inode->inode = &ibuffer[offset % INODES_PER_PAGE];
|
||||
|
||||
DPRINT("inode->i_uid %d\n",Inode->inode->i_uid);
|
||||
DPRINT("inode->i_links_count %d\n",Inode->inode->i_links_count);
|
||||
DPRINT("inode->i_blocks %d\n",Inode->inode->i_blocks);
|
||||
|
||||
DPRINT("Ext2LoadInode() finished\n");
|
||||
}
|
||||
|
||||
VOID Ext2ReleaseInode(PDEVICE_EXTENSION DeviceExt,
|
||||
PEXT2_INODE Inode)
|
||||
{
|
||||
CcReleaseCachePage(DeviceExt->Bcb,
|
||||
Inode->CacheSeg,
|
||||
TRUE);
|
||||
Inode->CacheSeg = NULL;
|
||||
Inode->BaseAddress = NULL;
|
||||
Inode->inode = NULL;
|
||||
}
|
||||
|
||||
VOID Ext2ReadInode(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG ino,
|
||||
struct ext2_inode* inode)
|
||||
{
|
||||
ULONG block_group;
|
||||
struct ext2_group_desc* gdp;
|
||||
ULONG offset;
|
||||
struct ext2_inode* buffer;
|
||||
|
||||
DPRINT("Ext2ReadInode(DeviceExt %x, ino %d, inode %x)\n",
|
||||
DeviceExt,ino,inode);
|
||||
|
||||
block_group = (ino - 1) / DeviceExt->superblock->s_inodes_per_group;
|
||||
|
||||
gdp = Ext2LoadGroupDesc(DeviceExt, block_group);
|
||||
|
||||
|
||||
|
||||
offset = (ino - 1) % DeviceExt->superblock->s_inodes_per_group;
|
||||
|
||||
buffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
|
||||
Ext2ReadSectors(DeviceExt->StorageDevice,
|
||||
gdp->bg_inode_table + (offset / INODES_PER_BLOCK),
|
||||
1,
|
||||
buffer);
|
||||
memcpy(inode,&buffer[offset % INODES_PER_BLOCK],sizeof(struct ext2_inode));
|
||||
|
||||
DPRINT("inode->i_uid %d\n",inode->i_uid);
|
||||
DPRINT("inode->i_links_count %d\n",inode->i_links_count);
|
||||
DPRINT("inode->i_blocks %d\n",inode->i_blocks);
|
||||
|
||||
}
|
49
rosapps/ext2/quota.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/quota.c
|
||||
* PURPOSE: Quota support
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2QueryQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2SetQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
219
rosapps/ext2/rw.c
Normal file
|
@ -0,0 +1,219 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/super.c
|
||||
* PURPOSE: ext2 filesystem
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS Ext2ReadPage(PDEVICE_EXTENSION DeviceExt,
|
||||
PEXT2_FCB Fcb,
|
||||
PVOID Buffer,
|
||||
ULONG Offset)
|
||||
{
|
||||
ULONG block, i;
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
block = Ext2BlockMap(DeviceExt,
|
||||
Fcb->i.inode,
|
||||
Offset + i);
|
||||
Ext2ReadSectors(DeviceExt->StorageDevice,
|
||||
block,
|
||||
1,
|
||||
Buffer + (i*BLOCKSIZE));
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS Ext2ReadFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT FileObject,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
LARGE_INTEGER OffsetL)
|
||||
{
|
||||
PVOID BaseAddress;
|
||||
BOOLEAN Uptodate = FALSE;
|
||||
PCACHE_SEGMENT CacheSeg;
|
||||
ULONG Offset = (ULONG)OffsetL.u.LowPart;
|
||||
PEXT2_FCB Fcb;
|
||||
ULONG block, i, Delta;
|
||||
DPRINT("Ext2ReadFile(DeviceExt %x, FileObject %x, Buffer %x, Length %d, \n"
|
||||
"OffsetL %d)\n",DeviceExt,FileObject,Buffer,Length,(ULONG)OffsetL);
|
||||
|
||||
Fcb = (PEXT2_FCB)FileObject->FsContext;
|
||||
|
||||
Ext2LoadInode(DeviceExt,
|
||||
Fcb->inode,
|
||||
&Fcb->i);
|
||||
|
||||
if (Offset >= Fcb->i.inode->i_size)
|
||||
{
|
||||
DPRINT("Returning end of file\n");
|
||||
return(STATUS_END_OF_FILE);
|
||||
}
|
||||
if ((Offset + Length) > Fcb->i.inode->i_size)
|
||||
{
|
||||
Length = Fcb->i.inode->i_size - Offset;
|
||||
}
|
||||
|
||||
Ext2ReleaseInode(DeviceExt,
|
||||
&Fcb->i);
|
||||
|
||||
if ((Offset % PAGE_SIZE) != 0)
|
||||
{
|
||||
Delta = min(PAGE_SIZE - (Offset % PAGE_SIZE),Length);
|
||||
CcRequestCachePage(Fcb->Bcb,
|
||||
Offset,
|
||||
&BaseAddress,
|
||||
&Uptodate,
|
||||
&CacheSeg);
|
||||
if (Uptodate == FALSE)
|
||||
{
|
||||
Ext2ReadPage(DeviceExt,
|
||||
Fcb,
|
||||
BaseAddress,
|
||||
Offset / BLOCKSIZE);
|
||||
}
|
||||
memcpy(Buffer, BaseAddress + (Offset % PAGE_SIZE), Delta);
|
||||
CcReleaseCachePage(Fcb->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
Length = Length - Delta;
|
||||
Offset = Offset + Delta;
|
||||
Buffer = Buffer + Delta;
|
||||
}
|
||||
CHECKPOINT;
|
||||
for (i=0; i<(Length/PAGE_SIZE); i++)
|
||||
{
|
||||
CcRequestCachePage(Fcb->Bcb,
|
||||
Offset,
|
||||
&BaseAddress,
|
||||
&Uptodate,
|
||||
&CacheSeg);
|
||||
if (Uptodate == FALSE)
|
||||
{
|
||||
Ext2ReadPage(DeviceExt,
|
||||
Fcb,
|
||||
BaseAddress,
|
||||
(Offset / BLOCKSIZE));
|
||||
}
|
||||
memcpy(Buffer, BaseAddress, PAGE_SIZE);
|
||||
CcReleaseCachePage(Fcb->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
Length = Length - PAGE_SIZE;
|
||||
Offset = Offset + PAGE_SIZE;
|
||||
Buffer = Buffer + PAGE_SIZE;
|
||||
}
|
||||
CHECKPOINT;
|
||||
if ((Length % PAGE_SIZE) != 0)
|
||||
{
|
||||
CcRequestCachePage(Fcb->Bcb,
|
||||
Offset,
|
||||
&BaseAddress,
|
||||
&Uptodate,
|
||||
&CacheSeg);
|
||||
if (Uptodate == FALSE)
|
||||
{
|
||||
Ext2ReadPage(DeviceExt,
|
||||
Fcb,
|
||||
BaseAddress,
|
||||
(Offset / BLOCKSIZE));
|
||||
}
|
||||
DPRINT("Copying %x to %x Length %d\n",BaseAddress,Buffer,Length);
|
||||
memcpy(Buffer,BaseAddress,Length);
|
||||
CcReleaseCachePage(Fcb->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
}
|
||||
CHECKPOINT;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2Write(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DPRINT("Ext2Write(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||
Irp->IoStatus.Information = 0;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2FlushBuffers(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DPRINT("Ext2FlushBuffers(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2Shutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DPRINT("Ext2Shutdown(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2Cleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DbgPrint("Ext2Cleanup(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
DbgPrint("Ext2Cleanup() finished\n");
|
||||
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2Read(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
ULONG Length;
|
||||
PVOID Buffer;
|
||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
||||
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("Ext2Read(DeviceObject %x, FileObject %x, Irp %x)\n",
|
||||
DeviceObject, FileObject, Irp);
|
||||
|
||||
Length = Stack->Parameters.Read.Length;
|
||||
CHECKPOINT;
|
||||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||
CHECKPOINT;
|
||||
CHECKPOINT;
|
||||
|
||||
Status = Ext2ReadFile(DeviceExt,FileObject,Buffer,Length,
|
||||
Stack->Parameters.Read.ByteOffset);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Length;
|
||||
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
}
|
41
rosapps/ext2/security.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/security.c
|
||||
* PURPOSE: Security support
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2QuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DPRINT("Ext2QuerySecurity(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2SetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
DPRINT("Ext2SetSecurity(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
201
rosapps/ext2/super.c
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/ext2/super.c
|
||||
* PURPOSE: ext2 filesystem
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
static PDRIVER_OBJECT DriverObject;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2Close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PFILE_OBJECT FileObject;
|
||||
PDEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
PEXT2_FCB Fcb;
|
||||
|
||||
DbgPrint("Ext2Close(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileObject = Stack->FileObject;
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
|
||||
if (FileObject == DeviceExtension->FileObject)
|
||||
{
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
Fcb = (PEXT2_FCB)FileObject->FsContext;
|
||||
if (Fcb != NULL)
|
||||
{
|
||||
if (Fcb->Bcb != NULL)
|
||||
{
|
||||
CcRosReleaseFileCache(FileObject, Fcb->Bcb);
|
||||
}
|
||||
ExFreePool(Fcb);
|
||||
FileObject->FsContext = NULL;
|
||||
}
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS Ext2Mount(PDEVICE_OBJECT DeviceToMount)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
PVOID BlockBuffer;
|
||||
struct ext2_super_block* superblock;
|
||||
|
||||
DPRINT("Ext2Mount(DeviceToMount %x)\n",DeviceToMount);
|
||||
|
||||
BlockBuffer = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
||||
Ext2ReadSectors(DeviceToMount,
|
||||
1,
|
||||
1,
|
||||
BlockBuffer);
|
||||
superblock = BlockBuffer;
|
||||
|
||||
if (superblock->s_magic != EXT2_SUPER_MAGIC)
|
||||
{
|
||||
ExFreePool(BlockBuffer);
|
||||
return(STATUS_UNRECOGNIZED_VOLUME);
|
||||
}
|
||||
DPRINT("Volume recognized\n");
|
||||
DPRINT("s_inodes_count %d\n",superblock->s_inodes_count);
|
||||
DPRINT("s_blocks_count %d\n",superblock->s_blocks_count);
|
||||
|
||||
IoCreateDevice(DriverObject,
|
||||
sizeof(DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
||||
DeviceExt = (PVOID)DeviceObject->DeviceExtension;
|
||||
DPRINT("DeviceExt %x\n",DeviceExt);
|
||||
|
||||
DeviceExt->StorageDevice = DeviceToMount;
|
||||
DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject;
|
||||
DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
|
||||
DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
|
||||
DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
|
||||
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
DPRINT("DeviceExt->StorageDevice %x\n", DeviceExt->StorageDevice);
|
||||
DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
|
||||
DeviceExt->superblock = superblock;
|
||||
CcRosInitializeFileCache(DeviceExt->FileObject,
|
||||
&DeviceExt->Bcb,
|
||||
PAGE_SIZE * 3);
|
||||
|
||||
DPRINT("Ext2Mount() = STATUS_SUCCESS\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
Ext2FileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PVPB vpb = Stack->Parameters.Mount.Vpb;
|
||||
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = Ext2Mount(DeviceToMount);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||
PUNICODE_STRING RegistryPath)
|
||||
/*
|
||||
* FUNCTION: Called by the system to initalize the driver
|
||||
* ARGUMENTS:
|
||||
* DriverObject = object describing this driver
|
||||
* RegistryPath = path to our configuration entries
|
||||
* RETURNS: Success or failure
|
||||
*/
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
NTSTATUS ret;
|
||||
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Ext2Fsd");
|
||||
|
||||
DbgPrint("Ext2 FSD 0.0.1\n");
|
||||
|
||||
DriverObject = _DriverObject;
|
||||
|
||||
ret = IoCreateDevice(DriverObject,
|
||||
0,
|
||||
&DeviceName,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (ret!=STATUS_SUCCESS)
|
||||
{
|
||||
return(ret);
|
||||
}
|
||||
|
||||
DeviceObject->Flags=0;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = Ext2Close;
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = Ext2Create;
|
||||
DriverObject->MajorFunction[IRP_MJ_READ] = Ext2Read;
|
||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = Ext2Write;
|
||||
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
||||
Ext2FileSystemControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
||||
Ext2DirectoryControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
|
||||
Ext2QueryInformation;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = Ext2SetInformation;
|
||||
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = Ext2FlushBuffers;
|
||||
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = Ext2Shutdown;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = Ext2Cleanup;
|
||||
DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = Ext2QuerySecurity;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] = Ext2SetSecurity;
|
||||
DriverObject->MajorFunction[IRP_MJ_QUERY_QUOTA] = Ext2QueryQuota;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_QUOTA] = Ext2SetQuota;
|
||||
|
||||
DriverObject->DriverUnload = NULL;
|
||||
|
||||
IoRegisterFileSystem(DeviceObject);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
394
rosapps/gettype/gettype.c
Normal file
|
@ -0,0 +1,394 @@
|
|||
/*
|
||||
* ReactOS Win32 Applications
|
||||
* Copyright (C) 2005 ReactOS Team
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS arp utility
|
||||
* FILE: apps/utils/gettype/gettype.c
|
||||
* PURPOSE:
|
||||
* PROGRAMMERS: Brandon Turner (turnerb7@msu.edu)
|
||||
* REVISIONS:
|
||||
* GM 30/10/05 Created
|
||||
*
|
||||
* FIXME: gettype only supports local computer.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <lm.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
enum
|
||||
{
|
||||
GETTYPE_ROLE = 0x001,
|
||||
GETTYPE_HELP = 0x002,
|
||||
GETTYPE_SP = 0x004,
|
||||
GETTYPE_VER = 0x008,
|
||||
GETTYPE_MINV = 0x010,
|
||||
GETTYPE_MAJV = 0x020,
|
||||
GETTYPE_TYPE = 0x040,
|
||||
GETTYPE_BUILD = 0x080
|
||||
};
|
||||
|
||||
INT
|
||||
GetVersionNumber(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
|
||||
{
|
||||
INT VersionNumber = 255;
|
||||
if(pBuf102 != NULL && !bLocal)
|
||||
{
|
||||
VersionNumber = pBuf102->sv102_version_major * 1000;
|
||||
VersionNumber += (pBuf102->sv102_version_minor * 100);
|
||||
}
|
||||
else if(bLocal)
|
||||
{
|
||||
VersionNumber = osvi->dwMajorVersion * 1000;
|
||||
VersionNumber += (osvi->dwMinorVersion * 100);
|
||||
}
|
||||
|
||||
return VersionNumber;
|
||||
}
|
||||
|
||||
INT
|
||||
GetMajValue(BOOL Major, BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
|
||||
{
|
||||
INT VersionNumber = 255;
|
||||
if(pBuf102 != NULL && !bLocal)
|
||||
{
|
||||
if(Major)
|
||||
VersionNumber = pBuf102->sv102_version_major * 1000;
|
||||
else
|
||||
VersionNumber = pBuf102->sv102_version_minor * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Major)
|
||||
VersionNumber = osvi->dwMajorVersion * 1000;
|
||||
else
|
||||
VersionNumber = osvi->dwMinorVersion * 100;
|
||||
}
|
||||
return VersionNumber;
|
||||
}
|
||||
|
||||
INT
|
||||
GetSystemRole(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
|
||||
{
|
||||
|
||||
if(pBuf102 != NULL && !bLocal)
|
||||
{
|
||||
if ((pBuf102->sv102_type & SV_TYPE_DOMAIN_CTRL) ||
|
||||
(pBuf102->sv102_type & SV_TYPE_DOMAIN_BAKCTRL))
|
||||
return 1;
|
||||
else if(pBuf102->sv102_type & SV_TYPE_SERVER_NT)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(osvi->wProductType == VER_NT_DOMAIN_CONTROLLER)
|
||||
return 1;
|
||||
else if(osvi->wProductType == VER_NT_SERVER)
|
||||
return 2;
|
||||
else if(osvi->wProductType == VER_NT_WORKSTATION)
|
||||
return 3;
|
||||
}
|
||||
return 255;
|
||||
|
||||
}
|
||||
|
||||
INT
|
||||
GetServicePack(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102, TCHAR * Server)
|
||||
{
|
||||
INT SPNumber = 255;
|
||||
if(!bLocal)
|
||||
{
|
||||
/* FIXME: Use Registry to get value */
|
||||
}
|
||||
else
|
||||
{
|
||||
SPNumber = osvi->wServicePackMajor;
|
||||
}
|
||||
return SPNumber;
|
||||
}
|
||||
|
||||
INT
|
||||
GetBuildNumber(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
|
||||
{
|
||||
INT BuildNum = 255;
|
||||
if(!bLocal)
|
||||
{
|
||||
/* FIXME: Use Registry to get value */
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildNum = osvi->dwBuildNumber;
|
||||
}
|
||||
return BuildNum;
|
||||
}
|
||||
|
||||
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
|
||||
{
|
||||
if(bLocal)
|
||||
{
|
||||
if(osvi->dwMajorVersion == 5)
|
||||
{
|
||||
if(osvi->dwMinorVersion == 1)
|
||||
{
|
||||
if(osvi->wSuiteMask & VER_SUITE_PERSONAL)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
else if(osvi->dwMinorVersion == 2)
|
||||
{
|
||||
if(osvi->wSuiteMask & VER_SUITE_BLADE)
|
||||
return 6;
|
||||
else if(osvi->wSuiteMask & VER_SUITE_DATACENTER)
|
||||
return 5;
|
||||
else if(osvi->wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||
return 4;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Get this value from registry */
|
||||
}
|
||||
return 255;
|
||||
}
|
||||
|
||||
VOID
|
||||
GetBasicInfo(LPOSVERSIONINFOEX osvi, TCHAR * HostName, TCHAR * OSName, TCHAR * Version, TCHAR * Role, TCHAR * Components)
|
||||
{
|
||||
/* Host Name - COMPUTERNAME*/
|
||||
DWORD bufCharCount = 1024;
|
||||
GetComputerName(HostName, &bufCharCount);
|
||||
|
||||
|
||||
/* OSName - Windows XP Home Editition */
|
||||
if(osvi->dwMajorVersion == 4)
|
||||
{
|
||||
_tcscpy(OSName, _T("Microsoft Windows NT 4.0 "));
|
||||
}
|
||||
else if(osvi->dwMajorVersion == 5)
|
||||
{
|
||||
if(osvi->dwMajorVersion == 0)
|
||||
{
|
||||
_tcscpy(OSName, _T("Microsoft Windows 2000 "));
|
||||
}
|
||||
else if(osvi->dwMinorVersion == 1)
|
||||
{
|
||||
_tcscpy(OSName, _T("Microsoft Windows XP "));
|
||||
}
|
||||
else if(osvi->dwMinorVersion == 2)
|
||||
{
|
||||
_tcscpy(OSName, _T("Microsoft Windows Server 2003 "));
|
||||
}
|
||||
}
|
||||
else if(osvi->dwMajorVersion == 6)
|
||||
{
|
||||
_tcscpy(OSName, _T("Microsoft Windows Vista "));
|
||||
}
|
||||
else
|
||||
{
|
||||
_tcscpy(OSName, _T("Microsoft Windows "));
|
||||
}
|
||||
|
||||
if(osvi->wSuiteMask & VER_SUITE_BLADE)
|
||||
_tcscat(OSName, _T("Web Edition"));
|
||||
if(osvi->wSuiteMask & VER_SUITE_DATACENTER)
|
||||
_tcscat(OSName, _T("Datacenter"));
|
||||
if(osvi->wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||
_tcscat(OSName, _T("Enterprise"));
|
||||
if(osvi->wSuiteMask & VER_SUITE_EMBEDDEDNT)
|
||||
_tcscat(OSName, _T("Embedded"));
|
||||
if(osvi->wSuiteMask & VER_SUITE_PERSONAL)
|
||||
_tcscat(OSName, _T("Home Edition"));
|
||||
if(osvi->wSuiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED && osvi->wSuiteMask & VER_SUITE_SMALLBUSINESS)
|
||||
_tcscat(OSName, _T("Small Bussiness Edition"));
|
||||
|
||||
/* Version - 5.1 Build 2600 Serivce Pack 2 */
|
||||
_stprintf(Version, _T("%d.%d Build %d %s"),(int)osvi->dwMajorVersion,(int)osvi->dwMinorVersion,(int)osvi->dwBuildNumber, osvi->szCSDVersion);
|
||||
|
||||
/* Role - Workgroup / Server / Domain Controller */
|
||||
if(osvi->wProductType == VER_NT_DOMAIN_CONTROLLER)
|
||||
_tcscpy(Role, _T("Domain Controller"));
|
||||
else if(osvi->wProductType == VER_NT_SERVER)
|
||||
_tcscpy(Role, _T("Server"));
|
||||
else if(osvi->wProductType == VER_NT_WORKSTATION)
|
||||
_tcscpy(Role, _T("Workgroup"));
|
||||
|
||||
/* Components - FIXME: what is something that might be installed? */
|
||||
_tcscat(Components, _T("Not Installed"));
|
||||
|
||||
}
|
||||
|
||||
INT
|
||||
main (VOID)
|
||||
{
|
||||
DWORD Operations = 0;
|
||||
INT ret = 255;
|
||||
INT i = 0;
|
||||
INT argc = 0;
|
||||
/* True if the target is local host */
|
||||
BOOL bLocal = TRUE;
|
||||
DWORD nStatus = 0;
|
||||
TCHAR ServerName[32];
|
||||
TCHAR RemoteResource[32];
|
||||
TCHAR UserName[32] = _T("");
|
||||
TCHAR Password[32] = _T("");
|
||||
LPOSVERSIONINFOEX osvi = NULL;
|
||||
LPSERVER_INFO_102 pBuf102 = NULL;
|
||||
LPTSTR * argv;
|
||||
osvi = (LPOSVERSIONINFOEX)malloc(sizeof(LPOSVERSIONINFOEX));
|
||||
pBuf102 = (LPSERVER_INFO_102)malloc(sizeof(LPSERVER_INFO_102));
|
||||
|
||||
/* Get the command line correctly since it is unicode */
|
||||
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
|
||||
|
||||
/* Process flags */
|
||||
if(argc)
|
||||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if(!_tcsicmp(argv[i], _T("/ROLE")) && !Operations)
|
||||
Operations |= GETTYPE_ROLE;
|
||||
else if(!_tcsicmp(argv[i], _T("/VER")) && !Operations)
|
||||
Operations |= GETTYPE_VER;
|
||||
else if(!_tcsicmp(argv[i], _T("/MAJV")) && !Operations)
|
||||
Operations |= GETTYPE_MAJV;
|
||||
else if(!_tcsicmp(argv[i], _T("/MINV")) && !Operations)
|
||||
Operations |= GETTYPE_MINV;
|
||||
else if(!_tcsicmp(argv[i], _T("/SP")) && !Operations)
|
||||
Operations |= GETTYPE_SP;
|
||||
else if(!_tcsicmp(argv[i], _T("/BUILD")) && !Operations)
|
||||
Operations |= GETTYPE_BUILD;
|
||||
else if(!_tcsicmp(argv[i], _T("/TYPE")) && !Operations)
|
||||
Operations |= GETTYPE_TYPE;
|
||||
else if(!_tcsicmp(argv[i], _T("/?")) && !Operations)
|
||||
Operations |= GETTYPE_HELP;
|
||||
else if(!_tcsicmp(argv[i], _T("/S")) && i + 1 < argc)
|
||||
{
|
||||
_tcscpy(ServerName,argv[++i]);
|
||||
bLocal = FALSE;
|
||||
}
|
||||
else if(!wcsicmp(argv[i], L"/U") && i + 1 < argc)
|
||||
_tcscpy(UserName,argv[++i]);
|
||||
else if(!wcsicmp(argv[i], L"/P") && i + 1 < argc)
|
||||
_tcscpy(Password,argv[++i]);
|
||||
else
|
||||
{
|
||||
wprintf(L"Error in paramters, please see usage\n");
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Some debug info */
|
||||
//_tprintf(_T("%s - %s - %s - %d"), ServerName, UserName, Password, (int)Operations);
|
||||
|
||||
if(!bLocal)
|
||||
{
|
||||
NETRESOURCE nr;
|
||||
|
||||
|
||||
/* \\*IP or Computer Name*\*Share* */
|
||||
_stprintf(RemoteResource, _T("\\\\%s\\IPC$"), ServerName);
|
||||
|
||||
nr.dwType = RESOURCETYPE_ANY;
|
||||
nr.lpLocalName = NULL;
|
||||
nr.lpProvider= NULL;
|
||||
nr.lpRemoteName = RemoteResource;
|
||||
|
||||
/* open a connection to the server with difference user/pass. */
|
||||
nStatus = WNetAddConnection2(&nr, UserName[0]?UserName:NULL,Password[0]?Password:NULL, CONNECT_INTERACTIVE | CONNECT_COMMANDLINE);
|
||||
|
||||
if(nStatus != NO_ERROR)
|
||||
{
|
||||
_tprintf(_T("Error:%d-%d\n"),(int)nStatus,GetLastError());
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
|
||||
/* Use GetVersionEx for anything that we are looking for locally */
|
||||
if(bLocal)
|
||||
{
|
||||
osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
if(!GetVersionEx((LPOSVERSIONINFO)osvi))
|
||||
{
|
||||
_tprintf(_T("Failed to get local information\n"));
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nStatus = NetServerGetInfo(NULL,102,(LPBYTE *)&pBuf102);
|
||||
if (nStatus != NERR_Success)
|
||||
{
|
||||
_tprintf(_T("Failed to connection to remote machine\n"));
|
||||
return 255;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(Operations & GETTYPE_VER)
|
||||
{
|
||||
ret = GetVersionNumber(bLocal, osvi, pBuf102);
|
||||
}
|
||||
else if(Operations & GETTYPE_MAJV)
|
||||
{
|
||||
ret = GetMajValue(TRUE, bLocal, osvi, pBuf102);
|
||||
}
|
||||
else if(Operations & GETTYPE_MINV)
|
||||
{
|
||||
ret = GetMajValue(FALSE, bLocal, osvi, pBuf102);
|
||||
}
|
||||
else if(Operations & GETTYPE_ROLE)
|
||||
{
|
||||
ret = GetSystemRole(bLocal, osvi, pBuf102);
|
||||
}
|
||||
else if(Operations & GETTYPE_SP)
|
||||
{
|
||||
ret = GetServicePack(bLocal, osvi, pBuf102, ServerName);
|
||||
}
|
||||
else if(Operations & GETTYPE_BUILD)
|
||||
{
|
||||
ret = GetBuildNumber(bLocal, osvi, pBuf102);
|
||||
}
|
||||
else if(Operations & GETTYPE_TYPE)
|
||||
{
|
||||
ret = GetType(bLocal, osvi, pBuf102);
|
||||
}
|
||||
else if(Operations & GETTYPE_HELP)
|
||||
{
|
||||
wprintf(L"GETTYPE [/ROLE | /SP | /VER | /MAJV | /MINV | /TYPE | /BUILD]");
|
||||
ret = 0;
|
||||
}
|
||||
else if(!Operations && bLocal)
|
||||
{
|
||||
/* FIXME: what happens when no flags except remote machine, does it
|
||||
it print this info for the remote server? */
|
||||
TCHAR HostName[1024] = _T("");
|
||||
TCHAR OSName[1024] = _T("");
|
||||
TCHAR VersionInfo[1024] = _T("");
|
||||
TCHAR Role[1024] = _T("");
|
||||
TCHAR Components[1024] = _T("");
|
||||
GetBasicInfo(osvi, HostName, OSName, VersionInfo, Role, Components);
|
||||
_tprintf(_T("\nHostname: %s\nName: %s\nVersion:%s\n") ,HostName, OSName, VersionInfo);
|
||||
_tprintf(_T("Role: %s\nComponent: %s\n"), Role, Components);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
/* Clean up some stuff that that was opened */
|
||||
if(pBuf102)
|
||||
NetApiBufferFree(pBuf102);
|
||||
LocalFree(argv);
|
||||
if(!bLocal)
|
||||
{
|
||||
WNetCancelConnection2(RemoteResource,0,TRUE);
|
||||
}
|
||||
return ret;
|
||||
}
|
12
rosapps/gettype/gettype.rbuild
Normal file
|
@ -0,0 +1,12 @@
|
|||
<module name="gettype" type="win32cui" installbase="system32" installname="gettype.exe">
|
||||
<include base="gettype">.</include>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<library>kernel32</library>
|
||||
<library>shell32</library>
|
||||
<library>mpr</library>
|
||||
<library>netapi32</library>
|
||||
<file>gettype.c</file>
|
||||
</module>
|
38
rosapps/green/createclose.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/createclose.c
|
||||
* PURPOSE: IRP_MJ_CREATE, IRP_MJ_CLOSE and IRP_MJ_CLEANUP operations
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
NTSTATUS
|
||||
GreenCreate(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
DPRINT("IRP_MJ_CREATE\n");
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
GreenClose(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
DPRINT("IRP_MJ_CLOSE\n");
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
105
rosapps/green/dispatch.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/dispatch.c
|
||||
* PURPOSE: Dispatch routines
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
NTSTATUS NTAPI
|
||||
GreenDispatch(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
ULONG MajorFunction;
|
||||
GREEN_DEVICE_TYPE DeviceType;
|
||||
ULONG_PTR Information;
|
||||
NTSTATUS Status;
|
||||
|
||||
MajorFunction = IoGetCurrentIrpStackLocation(Irp)->MajorFunction;
|
||||
DeviceType = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
|
||||
|
||||
Information = Irp->IoStatus.Information;
|
||||
Status = Irp->IoStatus.Status;
|
||||
|
||||
DPRINT("Dispatching major function 0x%lx, DeviceType %u\n",
|
||||
MajorFunction, DeviceType);
|
||||
|
||||
if (DeviceType == PassThroughFDO)
|
||||
{
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
|
||||
}
|
||||
else if (MajorFunction == IRP_MJ_CREATE && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
|
||||
return GreenCreate(DeviceObject, Irp);
|
||||
else if (MajorFunction == IRP_MJ_CLOSE && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
|
||||
return GreenClose(DeviceObject, Irp);
|
||||
else if ((MajorFunction == IRP_MJ_CREATE || MajorFunction == IRP_MJ_CLOSE || MajorFunction == IRP_MJ_CLEANUP)
|
||||
&& (DeviceType == KeyboardFDO || DeviceType == ScreenFDO))
|
||||
{
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
|
||||
}
|
||||
else if (MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL && DeviceType == GreenFDO)
|
||||
{
|
||||
return KeyboardInternalDeviceControl(
|
||||
((PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->KeyboardFdo,
|
||||
Irp);
|
||||
}
|
||||
else if (MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL && DeviceType == KeyboardFDO)
|
||||
return KeyboardInternalDeviceControl(DeviceObject, Irp);
|
||||
else if (MajorFunction == IRP_MJ_DEVICE_CONTROL && DeviceType == GreenFDO)
|
||||
{
|
||||
return ScreenDeviceControl(
|
||||
((PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ScreenFdo,
|
||||
Irp);
|
||||
}
|
||||
else if (MajorFunction == IRP_MJ_DEVICE_CONTROL && DeviceType == ScreenFDO)
|
||||
return ScreenDeviceControl(DeviceObject, Irp);
|
||||
else if (MajorFunction == IRP_MJ_WRITE && DeviceType == ScreenFDO)
|
||||
return ScreenWrite(DeviceObject, Irp);
|
||||
else if (MajorFunction == IRP_MJ_PNP && (DeviceType == KeyboardFDO || DeviceType == ScreenFDO))
|
||||
{
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
|
||||
}
|
||||
else if (MajorFunction == IRP_MJ_PNP && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
|
||||
return GreenPnp(DeviceObject, Irp);
|
||||
else if (MajorFunction == IRP_MJ_POWER && DeviceType == GreenFDO)
|
||||
return GreenPower(DeviceObject, Irp);
|
||||
else
|
||||
{
|
||||
DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
|
||||
MajorFunction, DeviceType);
|
||||
switch (DeviceType)
|
||||
{
|
||||
case KeyboardFDO:
|
||||
case ScreenFDO:
|
||||
{
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
|
||||
}
|
||||
case GreenFDO:
|
||||
{
|
||||
PDRIVER_OBJECT DriverObject;
|
||||
PGREEN_DRIVER_EXTENSION DriverExtension;
|
||||
DriverObject = DeviceObject->DriverObject;
|
||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DriverExtension->LowerDevice, Irp);
|
||||
}
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Information = Information;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
68
rosapps/green/green.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/green.c
|
||||
* PURPOSE: Driver entry point
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
VOID NTAPI
|
||||
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
||||
{
|
||||
// nothing to do here yet
|
||||
}
|
||||
|
||||
/*
|
||||
* Standard DriverEntry method.
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
DriverEntry(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
PGREEN_DRIVER_EXTENSION DriverExtension;
|
||||
ULONG i;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = IoAllocateDriverObjectExtension(
|
||||
DriverObject,
|
||||
DriverObject,
|
||||
sizeof(GREEN_DRIVER_EXTENSION),
|
||||
(PVOID*)&DriverExtension);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
RtlZeroMemory(DriverExtension, sizeof(GREEN_DRIVER_EXTENSION));
|
||||
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
0,
|
||||
RegistryPath,
|
||||
&DriverExtension->RegistryPath);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("RtlDuplicateUnicodeString() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = ReadRegistryEntries(RegistryPath, DriverExtension);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("ReadRegistryEntries() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DriverObject->DriverUnload = DriverUnload;
|
||||
DriverObject->DriverExtension->AddDevice = GreenAddDevice;
|
||||
|
||||
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
||||
DriverObject->MajorFunction[i] = GreenDispatch;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
192
rosapps/green/green.h
Normal file
|
@ -0,0 +1,192 @@
|
|||
#include <stdarg.h>
|
||||
#include <ntddk.h>
|
||||
#include <ndk/iotypes.h>
|
||||
#include <windef.h>
|
||||
#define WINBASEAPI
|
||||
typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES;
|
||||
#include <ntddser.h>
|
||||
#include <kbdmou.h>
|
||||
#include <wincon.h>
|
||||
#include <drivers/blue/ntddblue.h>
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
RtlDuplicateUnicodeString(
|
||||
IN ULONG Flags,
|
||||
IN PCUNICODE_STRING SourceString,
|
||||
OUT PUNICODE_STRING DestinationString
|
||||
);
|
||||
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
|
||||
|
||||
#define INFINITE -1
|
||||
#define KEYBOARD_BUFFER_SIZE 100
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GreenPDO,
|
||||
ScreenPDO,
|
||||
KeyboardPDO,
|
||||
GreenFDO,
|
||||
ScreenFDO,
|
||||
KeyboardFDO,
|
||||
PassThroughFDO,
|
||||
} GREEN_DEVICE_TYPE;
|
||||
|
||||
typedef struct _COMMON_DEVICE_EXTENSION
|
||||
{
|
||||
GREEN_DEVICE_TYPE Type;
|
||||
} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
|
||||
|
||||
/* For PassThroughFDO devices */
|
||||
typedef struct _COMMON_FDO_DEVICE_EXTENSION
|
||||
{
|
||||
GREEN_DEVICE_TYPE Type;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
} COMMON_FDO_DEVICE_EXTENSION, *PCOMMON_FDO_DEVICE_EXTENSION;
|
||||
|
||||
/* For KeyboardFDO devices */
|
||||
typedef struct _KEYBOARD_DEVICE_EXTENSION
|
||||
{
|
||||
COMMON_FDO_DEVICE_EXTENSION Common;
|
||||
PDEVICE_OBJECT Green;
|
||||
|
||||
CONNECT_DATA ClassInformation;
|
||||
HANDLE WorkerThreadHandle;
|
||||
KDPC KeyboardDpc;
|
||||
|
||||
ULONG ActiveQueue;
|
||||
ULONG InputDataCount[2];
|
||||
KEYBOARD_INPUT_DATA KeyboardInputData[2][KEYBOARD_BUFFER_SIZE];
|
||||
} KEYBOARD_DEVICE_EXTENSION, *PKEYBOARD_DEVICE_EXTENSION;
|
||||
|
||||
/* For ScreenFDO devices */
|
||||
typedef struct _SCREEN_DEVICE_EXTENSION
|
||||
{
|
||||
COMMON_FDO_DEVICE_EXTENSION Common;
|
||||
PDEVICE_OBJECT Green;
|
||||
|
||||
PUCHAR VideoMemory; /* Pointer to video memory */
|
||||
USHORT CharAttribute; /* Current color attribute */
|
||||
ULONG Mode;
|
||||
UCHAR ScanLines; /* Height of a text line */
|
||||
UCHAR Rows; /* Number of rows */
|
||||
UCHAR Columns; /* Number of columns */
|
||||
UCHAR TabWidth;
|
||||
|
||||
ULONG LogicalOffset; /* Position of the cursor */
|
||||
|
||||
UCHAR SendBuffer[1024];
|
||||
ULONG SendBufferPosition;
|
||||
PDEVICE_OBJECT PreviousBlue;
|
||||
} SCREEN_DEVICE_EXTENSION, *PSCREEN_DEVICE_EXTENSION;
|
||||
|
||||
/* For GreenFDO devices */
|
||||
typedef struct _GREEN_DEVICE_EXTENSION
|
||||
{
|
||||
COMMON_FDO_DEVICE_EXTENSION Common;
|
||||
PDEVICE_OBJECT Serial;
|
||||
|
||||
SERIAL_LINE_CONTROL LineControl;
|
||||
SERIAL_TIMEOUTS Timeouts;
|
||||
|
||||
PDEVICE_OBJECT KeyboardPdo;
|
||||
PDEVICE_OBJECT ScreenPdo;
|
||||
PDEVICE_OBJECT KeyboardFdo;
|
||||
PDEVICE_OBJECT ScreenFdo;
|
||||
} GREEN_DEVICE_EXTENSION, *PGREEN_DEVICE_EXTENSION;
|
||||
|
||||
typedef struct _GREEN_DRIVER_EXTENSION
|
||||
{
|
||||
UNICODE_STRING RegistryPath;
|
||||
|
||||
UNICODE_STRING AttachedDeviceName;
|
||||
ULONG DeviceReported;
|
||||
ULONG SampleRate;
|
||||
|
||||
PDEVICE_OBJECT GreenMainDO;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
} GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
|
||||
|
||||
/************************************ createclose.c */
|
||||
|
||||
NTSTATUS
|
||||
GreenCreate(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
GreenClose(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/************************************ dispatch.c */
|
||||
|
||||
NTSTATUS NTAPI
|
||||
GreenDispatch(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/************************************ keyboard.c */
|
||||
|
||||
NTSTATUS
|
||||
KeyboardAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo);
|
||||
|
||||
NTSTATUS
|
||||
KeyboardInternalDeviceControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/************************************ misc.c */
|
||||
|
||||
NTSTATUS
|
||||
GreenDeviceIoControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN ULONG CtlCode,
|
||||
IN PVOID InputBuffer OPTIONAL,
|
||||
IN ULONG InputBufferSize,
|
||||
IN OUT PVOID OutputBuffer OPTIONAL,
|
||||
IN OUT PULONG OutputBufferSize);
|
||||
|
||||
NTSTATUS
|
||||
ReadRegistryEntries(
|
||||
IN PUNICODE_STRING RegistryPath,
|
||||
IN PGREEN_DRIVER_EXTENSION DriverExtension);
|
||||
|
||||
/************************************ pnp.c */
|
||||
|
||||
NTSTATUS NTAPI
|
||||
GreenAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo);
|
||||
|
||||
NTSTATUS
|
||||
GreenPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/************************************ power.c */
|
||||
|
||||
NTSTATUS
|
||||
GreenPower(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/************************************ screen.c */
|
||||
|
||||
NTSTATUS
|
||||
ScreenAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo);
|
||||
|
||||
NTSTATUS
|
||||
ScreenWrite(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
ScreenDeviceControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
96
rosapps/green/green.inf
Normal file
|
@ -0,0 +1,96 @@
|
|||
; GREEN.INF
|
||||
|
||||
; Installation file for Green (VT100 server emulator) driver
|
||||
|
||||
[Version]
|
||||
Signature = "$Windows NT$"
|
||||
;Signature = "$ReactOS$"
|
||||
LayoutFile = layout.inf
|
||||
Class = System
|
||||
ClassGUID = {4D36E97D-E325-11CE-BFC1-08002BE10318}
|
||||
Provider = %ReactOS%
|
||||
DriverVer = 12/7/2005,1.00
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir = 12
|
||||
|
||||
[Manufacturer]
|
||||
%ReactOSMfg% = ReactOSMfg
|
||||
|
||||
[ReactOSMfg]
|
||||
%KEYBOARD.DeviceDesc% = Keyboard_Inst,GREEN\KEYBOARD
|
||||
%SCREEN.DeviceDesc% = Screen_Inst,GREEN\SCREEN
|
||||
|
||||
;----------------------------- GREEN DRIVER -----------------------------
|
||||
|
||||
[DefaultInstall.NT]
|
||||
CopyFiles = Green_CopyFiles.NT
|
||||
AddReg = Green_AddReg.NT
|
||||
|
||||
[Green_CopyFiles.NT]
|
||||
green.sys
|
||||
|
||||
[DefaultInstall.NT.Services]
|
||||
AddService = green, 0x00000002, green_Service_Inst
|
||||
|
||||
[green_Service_Inst]
|
||||
ServiceType = 1
|
||||
StartType = 1
|
||||
ErrorControl = 0
|
||||
ServiceBinary = %12%\green.sys
|
||||
LoadOrderGroup = Extended base
|
||||
Description = %GREEN.DriverDesc%
|
||||
Dependencies = blue, serial
|
||||
|
||||
[Green_AddReg.NT]
|
||||
HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters","AttachedDevice",0x00000000,"\Device\Serial1"
|
||||
|
||||
[DefaultUninstall.NT]
|
||||
DelFiles = Green_DelFiles.NT
|
||||
DelReg = Green_DelReg.NT
|
||||
|
||||
[DefaultUninstall.NT.Services]
|
||||
DelService = green, 0x00000200
|
||||
|
||||
[Green_DelFiles.NT]
|
||||
green.sys,,,0x00000001
|
||||
|
||||
[Green_DelReg.NT]
|
||||
HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters"
|
||||
|
||||
;---------------------------- KEYBOARD DEVICE ---------------------------
|
||||
|
||||
[Keyboard_Inst.NT]
|
||||
CopyFiles = Green_CopyFiles.NT
|
||||
Include = keyboard.inf
|
||||
Needs = STANDARD_Inst
|
||||
|
||||
[Keyboard_Inst.NT.HW]
|
||||
AddReg = Keyboard_AddReg.NT
|
||||
|
||||
[Keyboard_AddReg.NT]
|
||||
HKR, , "UpperFilters", 0x00010000, "kbdclass"
|
||||
|
||||
[Keyboard_Inst.NT.Services]
|
||||
AddService = green, 0x00000002, green_Service_Inst
|
||||
Include = msmouse.inf
|
||||
Needs = PS2_Inst.Services
|
||||
|
||||
;----------------------------- SCREEN DEVICE ----------------------------
|
||||
|
||||
[Screen_Inst.NT]
|
||||
CopyFiles = Green_CopyFiles.NT
|
||||
|
||||
[Screen_Inst.NT.Services]
|
||||
AddService = green, 0x00000002, green_Service_Inst
|
||||
|
||||
;-------------------------------- STRINGS -------------------------------
|
||||
|
||||
[Strings]
|
||||
ReactOS = "ReactOS Team"
|
||||
|
||||
GREEN.DriverDesc = "VT100 server emulator"
|
||||
|
||||
ReactOSMfg = "(ReactOS Team)"
|
||||
KEYBOARD.DeviceDesc = "Keyboard for remote console"
|
||||
SCREEN.DeviceDesc = "Screen for remote console"
|
16
rosapps/green/green.rbuild
Normal file
|
@ -0,0 +1,16 @@
|
|||
<module name="green" type="kernelmodedriver" installbase="system32/drivers" installname="green.sys">
|
||||
<bootstrap base="reactos" />
|
||||
<define name="__USE_W32API" />
|
||||
<library>ntoskrnl</library>
|
||||
<library>hal</library>
|
||||
<file>createclose.c</file>
|
||||
<file>dispatch.c</file>
|
||||
<file>green.c</file>
|
||||
<file>keyboard.c</file>
|
||||
<file>misc.c</file>
|
||||
<file>pnp.c</file>
|
||||
<file>power.c</file>
|
||||
<file>screen.c</file>
|
||||
<file>green.rc</file>
|
||||
<pch>green.h</pch>
|
||||
</module>
|
5
rosapps/green/green.rc
Normal file
|
@ -0,0 +1,5 @@
|
|||
#define REACTOS_VERSION_DLL
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "VT100 Server Driver\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "green\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "green.sys\0"
|
||||
#include <reactos/version.rc>
|
321
rosapps/green/keyboard.c
Normal file
|
@ -0,0 +1,321 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/dd/green/keyboard.c
|
||||
* PURPOSE: Keyboard part of green management
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
static BOOLEAN
|
||||
TranslateCharToScanCodes(
|
||||
IN PUCHAR InputBuffer,
|
||||
IN ULONG InputBufferSize,
|
||||
OUT KEYBOARD_INPUT_DATA* OutputBuffer,
|
||||
OUT PULONG OutputBufferSize,
|
||||
OUT PULONG BytesConsumed)
|
||||
{
|
||||
BOOLEAN NormalKey = FALSE;
|
||||
USHORT MakeCode;
|
||||
|
||||
if (InputBufferSize == 0)
|
||||
return FALSE;
|
||||
|
||||
switch (*InputBuffer)
|
||||
{
|
||||
case 0x1b: MakeCode = 0x01; NormalKey = TRUE; break; /* ESC */
|
||||
|
||||
case '1': MakeCode = 0x02; NormalKey = TRUE; break;
|
||||
case '2': MakeCode = 0x03; NormalKey = TRUE; break;
|
||||
case '3': MakeCode = 0x04; NormalKey = TRUE; break;
|
||||
case '4': MakeCode = 0x05; NormalKey = TRUE; break;
|
||||
case '5': MakeCode = 0x06; NormalKey = TRUE; break;
|
||||
case '6': MakeCode = 0x07; NormalKey = TRUE; break;
|
||||
case '7': MakeCode = 0x08; NormalKey = TRUE; break;
|
||||
case '8': MakeCode = 0x09; NormalKey = TRUE; break;
|
||||
case '9': MakeCode = 0x0a; NormalKey = TRUE; break;
|
||||
case '0': MakeCode = 0x0b; NormalKey = TRUE; break;
|
||||
case '-': MakeCode = 0x0c; NormalKey = TRUE; break;
|
||||
case '=': MakeCode = 0x0d; NormalKey = TRUE; break;
|
||||
case '\b': MakeCode = 0x0e; NormalKey = TRUE; break;
|
||||
|
||||
case '\t': MakeCode = 0x0f; NormalKey = TRUE; break;
|
||||
case 'q': MakeCode = 0x10; NormalKey = TRUE; break;
|
||||
case 'w': MakeCode = 0x11; NormalKey = TRUE; break;
|
||||
case 'e': MakeCode = 0x12; NormalKey = TRUE; break;
|
||||
case 'r': MakeCode = 0x13; NormalKey = TRUE; break;
|
||||
case 't': MakeCode = 0x14; NormalKey = TRUE; break;
|
||||
case 'y': MakeCode = 0x15; NormalKey = TRUE; break;
|
||||
case 'u': MakeCode = 0x16; NormalKey = TRUE; break;
|
||||
case 'i': MakeCode = 0x17; NormalKey = TRUE; break;
|
||||
case 'o': MakeCode = 0x18; NormalKey = TRUE; break;
|
||||
case 'p': MakeCode = 0x19; NormalKey = TRUE; break;
|
||||
case '[': MakeCode = 0x1a; NormalKey = TRUE; break;
|
||||
case ']': MakeCode = 0x1b; NormalKey = TRUE; break;
|
||||
|
||||
case '\r': MakeCode = 0x1c; NormalKey = TRUE; break;
|
||||
|
||||
case 'a': MakeCode = 0x1e; NormalKey = TRUE; break;
|
||||
case 's': MakeCode = 0x1f; NormalKey = TRUE; break;
|
||||
case 'd': MakeCode = 0x20; NormalKey = TRUE; break;
|
||||
case 'f': MakeCode = 0x21; NormalKey = TRUE; break;
|
||||
case 'g': MakeCode = 0x22; NormalKey = TRUE; break;
|
||||
case 'h': MakeCode = 0x23; NormalKey = TRUE; break;
|
||||
case 'j': MakeCode = 0x24; NormalKey = TRUE; break;
|
||||
case 'k': MakeCode = 0x25; NormalKey = TRUE; break;
|
||||
case 'l': MakeCode = 0x26; NormalKey = TRUE; break;
|
||||
case ';': MakeCode = 0x27; NormalKey = TRUE; break;
|
||||
case '\'': MakeCode = 0x28; NormalKey = TRUE; break;
|
||||
|
||||
case '`': MakeCode = 0x29; NormalKey = TRUE; break;
|
||||
|
||||
case '\\': MakeCode = 0x2b; NormalKey = TRUE; break;
|
||||
|
||||
case 'z': MakeCode = 0x2c; NormalKey = TRUE; break;
|
||||
case 'x': MakeCode = 0x2d; NormalKey = TRUE; break;
|
||||
case 'c': MakeCode = 0x2e; NormalKey = TRUE; break;
|
||||
case 'v': MakeCode = 0x2f; NormalKey = TRUE; break;
|
||||
case 'b': MakeCode = 0x30; NormalKey = TRUE; break;
|
||||
case 'n': MakeCode = 0x31; NormalKey = TRUE; break;
|
||||
case 'm': MakeCode = 0x32; NormalKey = TRUE; break;
|
||||
case ',': MakeCode = 0x33; NormalKey = TRUE; break;
|
||||
case '.': MakeCode = 0x34; NormalKey = TRUE; break;
|
||||
case '/': MakeCode = 0x35; NormalKey = TRUE; break;
|
||||
|
||||
case ' ': MakeCode = 0x39; NormalKey = TRUE; break;
|
||||
}
|
||||
if (NormalKey && *OutputBufferSize >= 2)
|
||||
{
|
||||
OutputBuffer[0].MakeCode = MakeCode;
|
||||
OutputBuffer[0].Flags = KEY_MAKE;
|
||||
OutputBuffer[1].MakeCode = MakeCode;
|
||||
OutputBuffer[1].Flags = KEY_BREAK;
|
||||
*BytesConsumed = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Consume strange character by ignoring it */
|
||||
DPRINT1("Strange byte received 0x%02x ('%c')\n",
|
||||
*InputBuffer, *InputBuffer >= 32 ? *InputBuffer : '.');
|
||||
*BytesConsumed = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
KeyboardAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo)
|
||||
{
|
||||
PDEVICE_OBJECT Fdo;
|
||||
PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("KeyboardInitialize() called\n");
|
||||
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(KEYBOARD_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_KEYBOARD,
|
||||
FILE_DEVICE_SECURE_OPEN,
|
||||
TRUE,
|
||||
&Fdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)Fdo->DeviceExtension;
|
||||
RtlZeroMemory(DeviceExtension, sizeof(KEYBOARD_DEVICE_EXTENSION));
|
||||
DeviceExtension->Common.Type = KeyboardFDO;
|
||||
DeviceExtension->Common.LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
|
||||
DeviceExtension->Green = ((PGREEN_DRIVER_EXTENSION)IoGetDriverObjectExtension(DriverObject, DriverObject))->GreenMainDO;
|
||||
((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->KeyboardFdo = Fdo;
|
||||
Fdo->Flags |= DO_POWER_PAGABLE | DO_BUFFERED_IO;
|
||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
KeyboardDpcSendData(
|
||||
IN PKDPC Dpc,
|
||||
IN PVOID pDeviceExtension, /* real type PKEYBOARD_DEVICE_EXTENSION */
|
||||
IN PVOID Unused1,
|
||||
IN PVOID Unused2)
|
||||
{
|
||||
PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
|
||||
ULONG Queue;
|
||||
ULONG InputDataConsumed;
|
||||
|
||||
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)pDeviceExtension;
|
||||
|
||||
Queue = DeviceExtension->ActiveQueue % 2;
|
||||
InterlockedIncrement((PLONG)&DeviceExtension->ActiveQueue);
|
||||
(*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassInformation.ClassService)(
|
||||
DeviceExtension->ClassInformation.ClassDeviceObject,
|
||||
DeviceExtension->KeyboardInputData[Queue],
|
||||
DeviceExtension->KeyboardInputData[Queue] + DeviceExtension->InputDataCount[Queue],
|
||||
&InputDataConsumed);
|
||||
|
||||
DeviceExtension->InputDataCount[Queue] = 0;
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
KeyboardDeviceWorker(
|
||||
PVOID Context)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
|
||||
PGREEN_DEVICE_EXTENSION GreenDeviceExtension;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
UCHAR Buffer[16]; /* Arbitrary size */
|
||||
ULONG BufferSize;
|
||||
LARGE_INTEGER Zero;
|
||||
PIRP Irp;
|
||||
IO_STATUS_BLOCK ioStatus;
|
||||
KEVENT event;
|
||||
KIRQL OldIrql;
|
||||
ULONG i, Queue;
|
||||
ULONG SpaceInQueue;
|
||||
ULONG BytesConsumed = 0;
|
||||
PKEYBOARD_INPUT_DATA Input;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("KeyboardDeviceWorker() called\n");
|
||||
|
||||
DeviceObject = (PDEVICE_OBJECT)Context;
|
||||
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension;
|
||||
LowerDevice = GreenDeviceExtension->Serial;
|
||||
BufferSize = sizeof(Buffer);
|
||||
Zero.QuadPart = 0;
|
||||
|
||||
/* Initialize device extension */
|
||||
DeviceExtension->ActiveQueue = 0;
|
||||
DeviceExtension->InputDataCount[0] = 0;
|
||||
DeviceExtension->InputDataCount[1] = 0;
|
||||
KeInitializeDpc(&DeviceExtension->KeyboardDpc, KeyboardDpcSendData, DeviceExtension);
|
||||
RtlZeroMemory(&DeviceExtension->KeyboardInputData, sizeof(DeviceExtension->KeyboardInputData));
|
||||
|
||||
/* main read loop */
|
||||
while (TRUE)
|
||||
{
|
||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||
Irp = IoBuildSynchronousFsdRequest(
|
||||
IRP_MJ_READ,
|
||||
LowerDevice,
|
||||
Buffer, BufferSize,
|
||||
&Zero,
|
||||
&event,
|
||||
&ioStatus);
|
||||
if (!Irp)
|
||||
{
|
||||
/* no memory actually, try later */
|
||||
CHECKPOINT;
|
||||
KeStallExecutionProcessor(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(LowerDevice, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL);
|
||||
Status = ioStatus.Status;
|
||||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
continue;
|
||||
|
||||
/* Read all available data and process */
|
||||
i = 0;
|
||||
while (i < ioStatus.Information)
|
||||
{
|
||||
Queue = DeviceExtension->ActiveQueue % 2;
|
||||
|
||||
Input = &DeviceExtension->KeyboardInputData[Queue][DeviceExtension->InputDataCount[Queue]];
|
||||
|
||||
/* Translate current chars to scan codes */
|
||||
SpaceInQueue = KEYBOARD_BUFFER_SIZE - DeviceExtension->InputDataCount[Queue];
|
||||
if (TranslateCharToScanCodes(
|
||||
&Buffer[i], /* input buffer */
|
||||
ioStatus.Information - i, /* input buffer size */
|
||||
Input, /* output buffer */
|
||||
&SpaceInQueue, /* output buffer size */
|
||||
&BytesConsumed)) /* bytes consumed in input buffer */
|
||||
{
|
||||
DPRINT("Got char 0x%02x (%c)\n", Buffer[i], Buffer[i] >= 32 ? Buffer[i] : ' ');
|
||||
DeviceExtension->InputDataCount[Queue] += BytesConsumed;
|
||||
|
||||
/* Send the data to the keyboard class driver */
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
||||
KeInsertQueueDpc(&DeviceExtension->KeyboardDpc, NULL, NULL);
|
||||
KeLowerIrql(OldIrql);
|
||||
i += BytesConsumed;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TranslateCharToScanCodes failed. Possible reasons:
|
||||
* - not enough bytes in input buffer (escape control code; wait next received bytes)
|
||||
* - not enough room in output buffer (wait for the Dpc to empty it)
|
||||
*
|
||||
* The best way to resolve this is to try later.
|
||||
*/
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PsTerminateSystemThread(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
KeyboardInternalDeviceControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
Irp->IoStatus.Information = 0;
|
||||
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
|
||||
{
|
||||
case IOCTL_INTERNAL_KEYBOARD_CONNECT:
|
||||
{
|
||||
DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
|
||||
if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
DeviceExtension->ClassInformation =
|
||||
*((PCONNECT_DATA)Stack->Parameters.DeviceIoControl.Type3InputBuffer);
|
||||
|
||||
/* Start read loop */
|
||||
Status = PsCreateSystemThread(
|
||||
&DeviceExtension->WorkerThreadHandle,
|
||||
(ACCESS_MASK)0L,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
KeyboardDeviceWorker,
|
||||
DeviceObject);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
|
||||
Stack->Parameters.DeviceIoControl.IoControlCode);
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
114
rosapps/green/misc.c
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/misc.c
|
||||
* PURPOSE: Misceallenous operations
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
NTSTATUS
|
||||
GreenDeviceIoControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN ULONG CtlCode,
|
||||
IN PVOID InputBuffer OPTIONAL,
|
||||
IN ULONG InputBufferSize,
|
||||
IN OUT PVOID OutputBuffer OPTIONAL,
|
||||
IN OUT PULONG OutputBufferSize)
|
||||
{
|
||||
KEVENT Event;
|
||||
PIRP Irp;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
NTSTATUS Status;
|
||||
|
||||
KeInitializeEvent (&Event, NotificationEvent, FALSE);
|
||||
|
||||
Irp = IoBuildDeviceIoControlRequest(CtlCode,
|
||||
DeviceObject,
|
||||
InputBuffer,
|
||||
InputBufferSize,
|
||||
OutputBuffer,
|
||||
(OutputBufferSize) ? *OutputBufferSize : 0,
|
||||
FALSE,
|
||||
&Event,
|
||||
&IoStatus);
|
||||
if (Irp == NULL)
|
||||
{
|
||||
DPRINT("IoBuildDeviceIoControlRequest() failed\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(DeviceObject, Irp);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
DPRINT("Operation pending\n");
|
||||
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||
Status = IoStatus.Status;
|
||||
}
|
||||
|
||||
if (OutputBufferSize)
|
||||
{
|
||||
*OutputBufferSize = IoStatus.Information;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ReadRegistryEntries(
|
||||
IN PUNICODE_STRING RegistryPath,
|
||||
IN PGREEN_DRIVER_EXTENSION DriverExtension)
|
||||
{
|
||||
UNICODE_STRING ParametersRegistryKey;
|
||||
RTL_QUERY_REGISTRY_TABLE Parameters[4];
|
||||
NTSTATUS Status;
|
||||
|
||||
ULONG DefaultDeviceReported = 0;
|
||||
ULONG DefaultSampleRate = 1200;
|
||||
|
||||
ParametersRegistryKey.Length = 0;
|
||||
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
||||
ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
|
||||
if (!ParametersRegistryKey.Buffer)
|
||||
{
|
||||
DPRINT("ExAllocatePool() failed\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
||||
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
||||
ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||
|
||||
RtlZeroMemory(Parameters, sizeof(Parameters));
|
||||
|
||||
Parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||
Parameters[0].Name = L"AttachedDevice";
|
||||
Parameters[0].EntryContext = &DriverExtension->AttachedDeviceName;
|
||||
|
||||
Parameters[1].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL;
|
||||
Parameters[1].Name = L"DeviceReported";
|
||||
Parameters[1].EntryContext = &DriverExtension->DeviceReported;
|
||||
Parameters[1].DefaultType = REG_DWORD;
|
||||
Parameters[1].DefaultData = &DefaultDeviceReported;
|
||||
Parameters[1].DefaultLength = sizeof(ULONG);
|
||||
|
||||
Parameters[2].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL;
|
||||
Parameters[2].Name = L"SampleRate";
|
||||
Parameters[2].EntryContext = &DriverExtension->SampleRate;
|
||||
Parameters[2].DefaultType = REG_DWORD;
|
||||
Parameters[2].DefaultData = &DefaultSampleRate;
|
||||
Parameters[2].DefaultLength = sizeof(ULONG);
|
||||
|
||||
Status = RtlQueryRegistryValues(
|
||||
RTL_REGISTRY_ABSOLUTE,
|
||||
ParametersRegistryKey.Buffer,
|
||||
Parameters,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return Status;
|
||||
}
|
562
rosapps/green/pnp.c
Normal file
|
@ -0,0 +1,562 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/pnp.c
|
||||
* PURPOSE: IRP_MJ_PNP operations
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
static NTSTATUS
|
||||
CreateGreenFdo(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT GreenPdo)
|
||||
{
|
||||
PGREEN_DRIVER_EXTENSION DriverExtension = NULL;
|
||||
PGREEN_DEVICE_EXTENSION DeviceExtension = NULL;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
ULONG Fcr;
|
||||
HANDLE LocalHandle = 0;
|
||||
ACCESS_MASK DesiredAccess = FILE_ANY_ACCESS;
|
||||
NTSTATUS Status;
|
||||
|
||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||
|
||||
Status = IoCreateDevice(
|
||||
DriverObject,
|
||||
sizeof(GREEN_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_TERMSRV,
|
||||
FILE_DEVICE_SECURE_OPEN,
|
||||
FALSE,
|
||||
&DriverExtension->GreenMainDO);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
DeviceExtension = (PGREEN_DEVICE_EXTENSION)DriverExtension->GreenMainDO->DeviceExtension;
|
||||
RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
|
||||
DeviceExtension->Common.Type = GreenFDO;
|
||||
DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
|
||||
DriverExtension->LowerDevice = IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
|
||||
|
||||
/* Initialize serial port */
|
||||
InitializeObjectAttributes(&ObjectAttributes, &DriverExtension->AttachedDeviceName, OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||
Status = ObOpenObjectByName(
|
||||
&ObjectAttributes,
|
||||
IoFileObjectType,
|
||||
KernelMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&LocalHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("ObOpenObjectByName() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
Status = ObReferenceObjectByHandle(
|
||||
LocalHandle,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
KernelMode,
|
||||
(PVOID*)&DeviceExtension->Serial,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("ObReferenceObjectByHandle() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
Fcr = 0;
|
||||
Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_FIFO_CONTROL,
|
||||
&Fcr, sizeof(Fcr), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_BAUD_RATE,
|
||||
&DriverExtension->SampleRate, sizeof(DriverExtension->SampleRate), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
DeviceExtension->LineControl.WordLength = 8;
|
||||
DeviceExtension->LineControl.Parity = NO_PARITY;
|
||||
DeviceExtension->LineControl.StopBits = STOP_BIT_1;
|
||||
Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_LINE_CONTROL,
|
||||
&DeviceExtension->LineControl, sizeof(SERIAL_LINE_CONTROL), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
RtlZeroMemory(&DeviceExtension->Timeouts, sizeof(SERIAL_TIMEOUTS));
|
||||
DeviceExtension->Timeouts.ReadIntervalTimeout = 100;
|
||||
Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_TIMEOUTS,
|
||||
&DeviceExtension->Timeouts, sizeof(SERIAL_TIMEOUTS), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
DriverExtension->GreenMainDO->Flags |= DO_BUFFERED_IO;
|
||||
DriverExtension->GreenMainDO->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
if (LocalHandle != 0)
|
||||
ZwClose(LocalHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (DeviceExtension && DeviceExtension->Serial)
|
||||
ObDereferenceObject(DeviceExtension->Serial);
|
||||
if (DriverExtension)
|
||||
{
|
||||
if (DriverExtension->LowerDevice)
|
||||
{
|
||||
IoDetachDevice(DriverExtension->LowerDevice);
|
||||
DriverExtension->LowerDevice = NULL;
|
||||
}
|
||||
if (DriverExtension->GreenMainDO)
|
||||
{
|
||||
IoDeleteDevice(DriverExtension->GreenMainDO);
|
||||
DriverExtension->GreenMainDO = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
ReportGreenPdo(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PGREEN_DRIVER_EXTENSION DriverExtension)
|
||||
{
|
||||
PDEVICE_OBJECT GreenPdo = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Create green PDO */
|
||||
Status = IoReportDetectedDevice(
|
||||
DriverObject,
|
||||
InterfaceTypeUndefined, -1, -1,
|
||||
NULL, NULL, TRUE,
|
||||
&GreenPdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoReportDetectedDevice() failed with status 0x%lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Create green FDO */
|
||||
Status = CreateGreenFdo(DriverObject, GreenPdo);
|
||||
|
||||
IoInvalidateDeviceRelations(GreenPdo, BusRelations);
|
||||
|
||||
/* FIXME: Update registry, set "DeviceReported" to 1 */
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (DriverExtension->GreenMainDO)
|
||||
IoDeleteDevice(DriverExtension->GreenMainDO);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
GreenAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo)
|
||||
{
|
||||
PGREEN_DRIVER_EXTENSION DriverExtension;
|
||||
|
||||
DPRINT("AddDevice(DriverObject %p, Pdo %p)\n", DriverObject, Pdo);
|
||||
|
||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||
|
||||
if (Pdo == NULL)
|
||||
{
|
||||
if (DriverExtension->DeviceReported)
|
||||
/* Green Pdo has already been reported during a previous boot.
|
||||
* We will get another AddDevice call soon.
|
||||
*/
|
||||
return STATUS_SUCCESS;
|
||||
else
|
||||
return ReportGreenPdo(DriverObject, DriverExtension);
|
||||
}
|
||||
else if (DriverExtension->GreenMainDO == NULL)
|
||||
{
|
||||
return CreateGreenFdo(DriverObject, Pdo);
|
||||
}
|
||||
else
|
||||
{
|
||||
PGREEN_DEVICE_EXTENSION GreenDeviceExtension;
|
||||
|
||||
GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DriverExtension->GreenMainDO->DeviceExtension;
|
||||
if (Pdo == GreenDeviceExtension->KeyboardPdo)
|
||||
return KeyboardAddDevice(DriverObject, Pdo);
|
||||
else if (Pdo == GreenDeviceExtension->ScreenPdo)
|
||||
return ScreenAddDevice(DriverObject, Pdo);
|
||||
else
|
||||
/* Strange PDO. We don't know it */
|
||||
ASSERT(FALSE);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
GreenQueryBusRelations(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
OUT PDEVICE_RELATIONS* pDeviceRelations)
|
||||
{
|
||||
PGREEN_DEVICE_EXTENSION DeviceExtension;
|
||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
/* Create PDOs for keyboard and screen */
|
||||
if (DeviceExtension->KeyboardPdo == NULL)
|
||||
{
|
||||
Status = IoCreateDevice(
|
||||
DeviceObject->DriverObject,
|
||||
sizeof(COMMON_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_KEYBOARD,
|
||||
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
|
||||
FALSE,
|
||||
&DeviceExtension->KeyboardPdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
((PCOMMON_DEVICE_EXTENSION)DeviceExtension->KeyboardPdo->DeviceExtension)->Type = KeyboardPDO;
|
||||
DeviceExtension->KeyboardPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
|
||||
DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
}
|
||||
|
||||
if (DeviceExtension->ScreenPdo == NULL)
|
||||
{
|
||||
Status = IoCreateDevice(
|
||||
DeviceObject->DriverObject,
|
||||
sizeof(COMMON_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_SCREEN,
|
||||
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
|
||||
FALSE,
|
||||
&DeviceExtension->ScreenPdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
|
||||
DeviceExtension->ScreenPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
|
||||
DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
}
|
||||
|
||||
/* Allocate return structure */
|
||||
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
|
||||
PagedPool,
|
||||
FIELD_OFFSET(DEVICE_RELATIONS, Objects) + 2 * sizeof(PDEVICE_OBJECT));
|
||||
if (!DeviceRelations)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
/* Fill return structure */
|
||||
DeviceRelations->Count = 2;
|
||||
ObReferenceObject(DeviceExtension->KeyboardPdo);
|
||||
ObReferenceObject(DeviceExtension->ScreenPdo);
|
||||
DeviceRelations->Objects[0] = DeviceExtension->KeyboardPdo;
|
||||
DeviceRelations->Objects[1] = DeviceExtension->ScreenPdo;
|
||||
|
||||
*pDeviceRelations = DeviceRelations;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (DeviceRelations)
|
||||
{
|
||||
ULONG i;
|
||||
for (i = 0; i < DeviceRelations->Count; i++)
|
||||
ObDereferenceObject(DeviceRelations->Objects[i]);
|
||||
ExFreePool(DeviceRelations);
|
||||
}
|
||||
if (DeviceExtension->KeyboardPdo)
|
||||
{
|
||||
IoDeleteDevice(DeviceExtension->KeyboardPdo);
|
||||
DeviceExtension->KeyboardPdo = NULL;
|
||||
}
|
||||
if (DeviceExtension->ScreenPdo)
|
||||
{
|
||||
IoDeleteDevice(DeviceExtension->ScreenPdo);
|
||||
DeviceExtension->ScreenPdo = NULL;
|
||||
}
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
GreenQueryId(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
OUT ULONG_PTR* Information)
|
||||
{
|
||||
GREEN_DEVICE_TYPE Type;
|
||||
ULONG IdType;
|
||||
NTSTATUS Status = Irp->IoStatus.Status;
|
||||
|
||||
Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
|
||||
IdType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
|
||||
|
||||
switch (IdType)
|
||||
{
|
||||
case BusQueryDeviceID:
|
||||
{
|
||||
LPCWSTR Source = NULL;
|
||||
|
||||
if (Type == ScreenPDO)
|
||||
Source = L"GREEN\\SCREEN";
|
||||
else if (Type == KeyboardPDO)
|
||||
Source = L"GREEN\\KEYBOARD";
|
||||
else
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceId / Unknown type 0x%lx\n",
|
||||
Type);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
|
||||
if (Source)
|
||||
{
|
||||
UNICODE_STRING SourceU, String;
|
||||
RtlInitUnicodeString(&SourceU, Source);
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&SourceU,
|
||||
&String);
|
||||
*Information = (ULONG_PTR)String.Buffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BusQueryHardwareIDs:
|
||||
{
|
||||
UNICODE_STRING SourceU = { 0, };
|
||||
|
||||
if (Type == ScreenPDO)
|
||||
{
|
||||
RtlInitUnicodeString(&SourceU, L"GREEN\\SCREEN\0");
|
||||
/* We can add the two \0 that are at the end of the string */
|
||||
SourceU.Length = SourceU.MaximumLength = SourceU.Length + 2 * sizeof(WCHAR);
|
||||
}
|
||||
else if (Type == KeyboardPDO)
|
||||
{
|
||||
RtlInitUnicodeString(&SourceU, L"GREEN\\KEYBOARD\0");
|
||||
/* We can add the two \0 that are at the end of the string */
|
||||
SourceU.Length = SourceU.MaximumLength = SourceU.Length + 2 * sizeof(WCHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs / Unknown type 0x%lx\n",
|
||||
Type);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
|
||||
if (SourceU.Length)
|
||||
{
|
||||
UNICODE_STRING String;
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&SourceU,
|
||||
&String);
|
||||
*Information = (ULONG_PTR)String.Buffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BusQueryCompatibleIDs:
|
||||
{
|
||||
/* We don't have any compatible ID */
|
||||
break;
|
||||
}
|
||||
case BusQueryInstanceID:
|
||||
{
|
||||
/* We don't have any instance ID */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
GreenPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
GREEN_DEVICE_TYPE Type;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = Irp->IoStatus.Information;
|
||||
NTSTATUS Status = Irp->IoStatus.Status;
|
||||
|
||||
Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
switch (Stack->MinorFunction)
|
||||
{
|
||||
case IRP_MN_START_DEVICE: /* 0x00 */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
if (Type == GreenFDO || Type == KeyboardPDO || Type == ScreenPDO)
|
||||
Status = STATUS_SUCCESS;
|
||||
else
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_START_DEVICE / Unknown type 0x%lx\n",
|
||||
Type);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS\n");
|
||||
switch (Stack->Parameters.QueryDeviceRelations.Type)
|
||||
{
|
||||
case BusRelations:
|
||||
{
|
||||
if (Type == GreenFDO)
|
||||
{
|
||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||
Status = GreenQueryBusRelations(DeviceObject, &DeviceRelations);
|
||||
Information = (ULONG_PTR)DeviceRelations;
|
||||
}
|
||||
else if (Type == KeyboardPDO || Type == ScreenPDO)
|
||||
{
|
||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||
DeviceRelations = ExAllocatePool(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects));
|
||||
if (!DeviceRelations)
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
else
|
||||
{
|
||||
DeviceRelations->Count = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
Information = (ULONG_PTR)DeviceRelations;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations / Unknown type 0x%lx\n",
|
||||
Type);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
|
||||
Stack->Parameters.QueryDeviceRelations.Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCES: /* 0x0a */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
|
||||
/* We don't need resources */
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
|
||||
/* We don't need resources */
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT\n");
|
||||
switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
|
||||
{
|
||||
case DeviceTextDescription:
|
||||
{
|
||||
LPCWSTR Description = NULL;
|
||||
if (Type == GreenFDO)
|
||||
Description = L"Green device";
|
||||
else if (Type == ScreenPDO)
|
||||
Description = L"Green screen";
|
||||
else if (Type == KeyboardPDO)
|
||||
Description = L"Green keyboard";
|
||||
|
||||
if (Description != NULL)
|
||||
{
|
||||
LPWSTR Destination = ExAllocatePool(PagedPool, wcslen(Description) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
|
||||
if (!Destination)
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
else
|
||||
{
|
||||
wcscpy(Destination, Description);
|
||||
Information = (ULONG_PTR)Description;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription / Unknown type 0x%lx\n",
|
||||
Type);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DeviceTextLocationInformation:
|
||||
{
|
||||
/* We don't have any text location to report,
|
||||
* and this query is optional, so ignore it.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
|
||||
Stack->Parameters.QueryDeviceText.DeviceTextType);
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_ID: /* 0x13 */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID\n");
|
||||
Status = GreenQueryId(DeviceObject, Irp, &Information);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / unknown minor function 0x%lx\n", Stack->MinorFunction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
if (Status != STATUS_PENDING)
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
58
rosapps/green/power.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/power.c
|
||||
* PURPOSE: IRP_MJ_POWER operations
|
||||
* PROGRAMMERS: Copyright 2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
NTSTATUS
|
||||
GreenPower(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
GREEN_DEVICE_TYPE Type;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = Irp->IoStatus.Information;
|
||||
NTSTATUS Status = Irp->IoStatus.Status;
|
||||
|
||||
Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
switch (Stack->MinorFunction)
|
||||
{
|
||||
case IRP_MN_SET_POWER: /* 0x02 */
|
||||
{
|
||||
DPRINT("IRP_MJ_POWER / IRP_MN_SET_POWER\n");
|
||||
if (Type == GreenFDO)
|
||||
{
|
||||
PoStartNextPowerIrp(Irp);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("IRP_MJ_POWER / IRP_MN_SET_POWER / Unknown type 0x%lx\n",
|
||||
Type);
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_POWER / unknown minor function 0x%lx\n", Stack->MinorFunction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
if (Status != STATUS_PENDING)
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return Status;
|
||||
}
|
674
rosapps/green/screen.c
Normal file
|
@ -0,0 +1,674 @@
|
|||
/*
|
||||
* PROJECT: ReactOS VT100 emulator
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/base/green/screen.c
|
||||
* PURPOSE: IRP_MJ_PNP operations
|
||||
* PROGRAMMERS: Copyright 2005 Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* Copyright 2005 Art Yerkes
|
||||
* Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "green.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define ESC ((UCHAR)0x1b)
|
||||
|
||||
/* Force a move of the cursor on each printer char.
|
||||
* Very useful for debug, but it is very slow...
|
||||
*/
|
||||
//#define FORCE_POSITION
|
||||
|
||||
/* UCHAR is promoted to int when passed through '...',
|
||||
* so we get int with va_arg and cast them back to UCHAR.
|
||||
*/
|
||||
static VOID
|
||||
AddToSendBuffer(
|
||||
IN PSCREEN_DEVICE_EXTENSION DeviceExtension,
|
||||
IN ULONG NumberOfChars,
|
||||
... /* IN int */)
|
||||
{
|
||||
PIRP Irp;
|
||||
IO_STATUS_BLOCK ioStatus;
|
||||
va_list args;
|
||||
PDEVICE_OBJECT SerialDevice;
|
||||
ULONG SizeLeft;
|
||||
int CurrentInt;
|
||||
UCHAR CurrentChar;
|
||||
NTSTATUS Status;
|
||||
LARGE_INTEGER ZeroOffset;
|
||||
|
||||
ZeroOffset.QuadPart = 0;
|
||||
|
||||
SizeLeft = sizeof(DeviceExtension->SendBuffer) - DeviceExtension->SendBufferPosition;
|
||||
if (SizeLeft < NumberOfChars * 2 || NumberOfChars == 0)
|
||||
{
|
||||
SerialDevice = ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->Serial;
|
||||
Irp = IoBuildSynchronousFsdRequest(
|
||||
IRP_MJ_WRITE,
|
||||
SerialDevice,
|
||||
DeviceExtension->SendBuffer, DeviceExtension->SendBufferPosition,
|
||||
&ZeroOffset,
|
||||
NULL, /* Event */
|
||||
&ioStatus);
|
||||
if (!Irp)
|
||||
{
|
||||
DPRINT1("IoBuildSynchronousFsdRequest() failed. Unable to flush output buffer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(SerialDevice, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_PENDING)
|
||||
{
|
||||
DPRINT1("IoCallDriver() failed. Status = 0x%08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
DeviceExtension->SendBufferPosition = 0;
|
||||
SizeLeft = sizeof(DeviceExtension->SendBuffer);
|
||||
}
|
||||
|
||||
va_start(args, NumberOfChars);
|
||||
while (NumberOfChars-- > 0)
|
||||
{
|
||||
CurrentInt = va_arg(args, int);
|
||||
|
||||
if (CurrentInt > 0)
|
||||
{
|
||||
CurrentChar = (UCHAR)CurrentInt;
|
||||
|
||||
/* Why 0xff chars are printed on a 'dir' ? */
|
||||
if (CurrentChar == 0xff) CurrentChar = ' ';
|
||||
|
||||
DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] = CurrentChar;
|
||||
SizeLeft--;
|
||||
}
|
||||
else if (CurrentInt == 0)
|
||||
{
|
||||
DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] = '0';
|
||||
SizeLeft--;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentInt = -CurrentInt;
|
||||
ASSERT(CurrentInt < 100);
|
||||
if (CurrentInt >= 10)
|
||||
{
|
||||
DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] =
|
||||
(CurrentInt / 10) % 10 + '0';
|
||||
SizeLeft--;
|
||||
}
|
||||
DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] =
|
||||
CurrentInt % 10 + '0';
|
||||
SizeLeft--;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ScreenAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo)
|
||||
{
|
||||
/* We want to be an upper filter of Blue, if it is existing.
|
||||
* We also *have to* create a Fdo on top of the given Pdo.
|
||||
* Hence, we have 2 cases:
|
||||
* - Blue doesn't exist -> Create a unique Fdo (named Blue) at
|
||||
* the top of the given Pdo
|
||||
* - Blue does exist -> Create a Fdo at the top of the existing
|
||||
* DO, and create a "pass to Green" FDO at the top of the Pdo
|
||||
*/
|
||||
PDEVICE_OBJECT Fdo = NULL;
|
||||
PDEVICE_OBJECT PassThroughFdo = NULL;
|
||||
PDEVICE_OBJECT LowerDevice = NULL;
|
||||
PDEVICE_OBJECT PreviousBlue = NULL;
|
||||
PSCREEN_DEVICE_EXTENSION DeviceExtension = NULL;
|
||||
UNICODE_STRING BlueScreenName = RTL_CONSTANT_STRING(L"\\Device\\BlueScreen");
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("ScreenInitialize() called\n");
|
||||
|
||||
/* Try to create a unique Fdo */
|
||||
Status = IoCreateDevice(
|
||||
DriverObject,
|
||||
sizeof(SCREEN_DEVICE_EXTENSION),
|
||||
&BlueScreenName,
|
||||
FILE_DEVICE_SCREEN,
|
||||
FILE_DEVICE_SECURE_OPEN,
|
||||
TRUE,
|
||||
&Fdo);
|
||||
|
||||
if (Status == STATUS_OBJECT_NAME_COLLISION)
|
||||
{
|
||||
DPRINT("Attaching to old blue\n");
|
||||
|
||||
/* Suggested by hpoussin .. Hide previous blue device
|
||||
* This makes us able to coexist with blue, and install
|
||||
* when loaded */
|
||||
Status = IoCreateDevice(
|
||||
DriverObject,
|
||||
sizeof(SCREEN_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_SCREEN,
|
||||
FILE_DEVICE_SECURE_OPEN,
|
||||
TRUE,
|
||||
&Fdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Initialize some fields, as IoAttachDevice will trigger the
|
||||
* sending of IRP_MJ_CLEANUP/IRP_MJ_CLOSE. We have to know where to
|
||||
* dispatch these IRPs... */
|
||||
((PSCREEN_DEVICE_EXTENSION)Fdo->DeviceExtension)->Common.Type = ScreenPDO;
|
||||
Status = IoAttachDevice(
|
||||
Fdo,
|
||||
&BlueScreenName,
|
||||
&LowerDevice);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoAttachDevice() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
PreviousBlue = LowerDevice;
|
||||
|
||||
/* Attach a faked FDO to PDO */
|
||||
Status = IoCreateDevice(
|
||||
DriverObject,
|
||||
sizeof(COMMON_FDO_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_SCREEN,
|
||||
FILE_DEVICE_SECURE_OPEN,
|
||||
TRUE,
|
||||
&PassThroughFdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
((PCOMMON_FDO_DEVICE_EXTENSION)PassThroughFdo->DeviceExtension)->Type = PassThroughFDO;
|
||||
((PCOMMON_FDO_DEVICE_EXTENSION)PassThroughFdo->DeviceExtension)->LowerDevice = Fdo;
|
||||
PassThroughFdo->StackSize = Fdo->StackSize + 1;
|
||||
}
|
||||
else if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Attach the named Fdo on top of Pdo */
|
||||
LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* We definately have a device object. PreviousBlue may or may
|
||||
* not be null */
|
||||
DeviceExtension = (PSCREEN_DEVICE_EXTENSION)Fdo->DeviceExtension;
|
||||
RtlZeroMemory(DeviceExtension, sizeof(SCREEN_DEVICE_EXTENSION));
|
||||
DeviceExtension->Common.Type = ScreenFDO;
|
||||
DeviceExtension->Common.LowerDevice = LowerDevice;
|
||||
DeviceExtension->Green = ((PGREEN_DRIVER_EXTENSION)IoGetDriverObjectExtension(DriverObject, DriverObject))->GreenMainDO;
|
||||
((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->ScreenFdo = Fdo;
|
||||
DeviceExtension->PreviousBlue = PreviousBlue;
|
||||
IoAttachDeviceToDeviceStack(PassThroughFdo ? PassThroughFdo : Fdo, Pdo);
|
||||
|
||||
/* initialize screen */
|
||||
DeviceExtension->Columns = 80;
|
||||
DeviceExtension->Rows = 25;
|
||||
DeviceExtension->ScanLines = 16;
|
||||
DeviceExtension->VideoMemory = (PUCHAR)ExAllocatePool(
|
||||
PagedPool,
|
||||
2 * DeviceExtension->Columns * DeviceExtension->Rows * sizeof(UCHAR));
|
||||
if (!DeviceExtension->VideoMemory)
|
||||
{
|
||||
DPRINT("ExAllocatePool() failed\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto cleanup;
|
||||
}
|
||||
DeviceExtension->TabWidth = 8;
|
||||
|
||||
/* more initialization */
|
||||
DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
|
||||
ENABLE_WRAP_AT_EOL_OUTPUT;
|
||||
|
||||
/* initialize screen at next write */
|
||||
AddToSendBuffer(DeviceExtension, 2, ESC, 'c'); /* reset device */
|
||||
AddToSendBuffer(DeviceExtension, 4, ESC, '[', '7', 'l'); /* disable line wrap */
|
||||
AddToSendBuffer(DeviceExtension, 4, ESC, '[', '3', 'g'); /* clear all tabs */
|
||||
|
||||
Fdo->Flags |= DO_POWER_PAGABLE;
|
||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (DeviceExtension)
|
||||
ExFreePool(DeviceExtension->VideoMemory);
|
||||
if (LowerDevice)
|
||||
IoDetachDevice(LowerDevice);
|
||||
if (Fdo)
|
||||
IoDeleteDevice(Fdo);
|
||||
if (PassThroughFdo)
|
||||
IoDeleteDevice(PassThroughFdo);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ScreenWrite(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PUCHAR Buffer;
|
||||
PSCREEN_DEVICE_EXTENSION DeviceExtension;
|
||||
PDEVICE_OBJECT SerialDevice;
|
||||
PUCHAR VideoMemory; /* FIXME: is it useful? */
|
||||
ULONG VideoMemorySize; /* FIXME: is it useful? */
|
||||
|
||||
ULONG Columns, Rows;
|
||||
ULONG CursorX, CursorY;
|
||||
ULONG i, j;
|
||||
|
||||
DPRINT("ScreenWrite() called\n");
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
Buffer = Irp->UserBuffer;
|
||||
DeviceExtension = (PSCREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
VideoMemory = DeviceExtension->VideoMemory;
|
||||
|
||||
SerialDevice = ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->Serial;
|
||||
if (!SerialDevice)
|
||||
{
|
||||
DPRINT1("Calling blue\n");
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->PreviousBlue, Irp);
|
||||
}
|
||||
|
||||
Columns = DeviceExtension->Columns;
|
||||
Rows = DeviceExtension->Rows;
|
||||
CursorX = (DeviceExtension->LogicalOffset / 2) % Columns + 1;
|
||||
CursorY = (DeviceExtension->LogicalOffset / 2) / Columns + 1;
|
||||
VideoMemorySize = Columns * Rows * 2 * sizeof(UCHAR);
|
||||
|
||||
if (!(DeviceExtension->Mode & ENABLE_PROCESSED_OUTPUT))
|
||||
{
|
||||
/* raw output mode */
|
||||
CHECKPOINT;
|
||||
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < Stack->Parameters.Write.Length; i++, Buffer++)
|
||||
{
|
||||
switch (*Buffer)
|
||||
{
|
||||
case '\b':
|
||||
{
|
||||
if (CursorX > 1)
|
||||
{
|
||||
CursorX--;
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
|
||||
AddToSendBuffer(DeviceExtension, 1, ' ');
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
|
||||
}
|
||||
else if (CursorY > 1)
|
||||
{
|
||||
CursorX = Columns;
|
||||
CursorY--;
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '\n':
|
||||
{
|
||||
CursorY++;
|
||||
CursorX = 1;
|
||||
AddToSendBuffer(DeviceExtension, 1, '\n');
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', '1', 'H');
|
||||
break;
|
||||
}
|
||||
case '\r':
|
||||
{
|
||||
if (CursorX > 1)
|
||||
{
|
||||
AddToSendBuffer(DeviceExtension, 4, ESC, '[', -(int)(CursorX-1), 'D');
|
||||
CursorX = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '\t':
|
||||
{
|
||||
ULONG Offset = DeviceExtension->TabWidth - (CursorX % DeviceExtension->TabWidth);
|
||||
for (j = 0; j < Offset; j++)
|
||||
{
|
||||
#ifdef FORCE_POSITION
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
|
||||
#endif
|
||||
AddToSendBuffer(DeviceExtension, 1, ' ');
|
||||
CursorX++;
|
||||
if (CursorX > Columns)
|
||||
{
|
||||
CursorX = 1;
|
||||
CursorY++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
#ifdef FORCE_POSITION
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
|
||||
#endif
|
||||
AddToSendBuffer(DeviceExtension, 1, *Buffer);
|
||||
CursorX++;
|
||||
if (CursorX > Columns)
|
||||
{
|
||||
CursorX = 1;
|
||||
DPRINT("Y: %lu -> %lu\n", CursorY, CursorY + 1);
|
||||
CursorY++;
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', '1', 'H');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CursorY >= Rows)
|
||||
{
|
||||
DPRINT("Y: %lu -> %lu\n", CursorY, CursorY - 1);
|
||||
CursorY--;
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)1, ';', -(int)(Rows), 'r');
|
||||
AddToSendBuffer(DeviceExtension, 2, ESC, 'D');
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeviceExtension->LogicalOffset = ((CursorX-1) + (CursorY-1) * Columns) * 2;
|
||||
|
||||
/* flush output buffer */
|
||||
AddToSendBuffer(DeviceExtension, 0);
|
||||
|
||||
/* Call lower driver */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->Common.LowerDevice, Irp);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ScreenDeviceControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PSCREEN_DEVICE_EXTENSION DeviceExtension;
|
||||
PDEVICE_OBJECT SerialDevice;
|
||||
NTSTATUS Status;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
DeviceExtension = (PSCREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
SerialDevice = ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->Serial;
|
||||
if (!SerialDevice)
|
||||
{
|
||||
DPRINT1("Calling blue\n");
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->PreviousBlue, Irp);
|
||||
}
|
||||
|
||||
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
|
||||
{
|
||||
#if 0
|
||||
case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO:
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER_INFO pcsbi;
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO\n");
|
||||
|
||||
pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
pcsbi->dwSize.X = DeviceExtension->Columns;
|
||||
pcsbi->dwSize.Y = DeviceExtension->Rows;
|
||||
|
||||
pcsbi->dwCursorPosition.X = (SHORT)(DeviceExtension->LogicalOffset % DeviceExtension->Columns);
|
||||
pcsbi->dwCursorPosition.Y = (SHORT)(DeviceExtension->LogicalOffset / DeviceExtension->Columns);
|
||||
|
||||
pcsbi->wAttributes = DeviceExtension->CharAttribute;
|
||||
|
||||
pcsbi->srWindow.Left = 1;
|
||||
pcsbi->srWindow.Right = DeviceExtension->Columns;
|
||||
pcsbi->srWindow.Top = 1;
|
||||
pcsbi->srWindow.Bottom = DeviceExtension->Rows;
|
||||
|
||||
pcsbi->dwMaximumWindowSize.X = DeviceExtension->Columns;
|
||||
pcsbi->dwMaximumWindowSize.Y = DeviceExtension->Rows;
|
||||
|
||||
Irp->IoStatus.Information = sizeof(CONSOLE_SCREEN_BUFFER_INFO);
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO:
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER_INFO pcsbi;
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO\n");
|
||||
|
||||
pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
|
||||
/* FIXME: remove */ { pcsbi->dwCursorPosition.X++; }
|
||||
/* FIXME: remove */ { pcsbi->dwCursorPosition.Y++; }
|
||||
ASSERT(pcsbi->dwCursorPosition.X >= 1);
|
||||
ASSERT(pcsbi->dwCursorPosition.Y >= 1);
|
||||
ASSERT(pcsbi->dwCursorPosition.X <= DeviceExtension->Columns);
|
||||
ASSERT(pcsbi->dwCursorPosition.Y <= DeviceExtension->Rows);
|
||||
|
||||
DeviceExtension->LogicalOffset = (
|
||||
(pcsbi->dwCursorPosition.Y-1) * DeviceExtension->Columns +
|
||||
(pcsbi->dwCursorPosition.X-1)) * 2;
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[',
|
||||
-(int)pcsbi->dwCursorPosition.Y, ';',
|
||||
-(int)pcsbi->dwCursorPosition.X, 'H');
|
||||
|
||||
/* flush buffer */
|
||||
AddToSendBuffer(DeviceExtension, 0);
|
||||
|
||||
DeviceExtension->CharAttribute = pcsbi->wAttributes;
|
||||
|
||||
Irp->IoStatus.Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_GET_CURSOR_INFO:
|
||||
{
|
||||
PCONSOLE_CURSOR_INFO pcci = (PCONSOLE_CURSOR_INFO)Irp->AssociatedIrp.SystemBuffer;
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_CURSOR_INFO\n");
|
||||
|
||||
pcci->dwSize = 1;
|
||||
pcci->bVisible = TRUE;
|
||||
|
||||
Irp->IoStatus.Information = sizeof (CONSOLE_CURSOR_INFO);
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_GET_MODE:
|
||||
{
|
||||
PCONSOLE_MODE pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_MODE\n");
|
||||
|
||||
pcm->dwMode = DeviceExtension->Mode;
|
||||
|
||||
Irp->IoStatus.Information = sizeof(CONSOLE_MODE);
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_SET_MODE:
|
||||
{
|
||||
PCONSOLE_MODE pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_MODE\n");
|
||||
|
||||
DeviceExtension->Mode = pcm->dwMode;
|
||||
|
||||
Irp->IoStatus.Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE */
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE */
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE */
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE:
|
||||
{
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE\n");
|
||||
|
||||
DeviceExtension->CharAttribute = (WORD)*(PWORD)Irp->AssociatedIrp.SystemBuffer;
|
||||
Irp->IoStatus.Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED; /* FIXME:IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER */
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_READ_OUTPUT_CHARACTER:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_CHARACTER\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_READ_OUTPUT_CHARACTER */
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER */
|
||||
break;
|
||||
}
|
||||
case IOCTL_CONSOLE_DRAW:
|
||||
{
|
||||
PCONSOLE_DRAW ConsoleDraw;
|
||||
PUCHAR Video;
|
||||
ULONG x, y;
|
||||
BOOLEAN DoOptimization = FALSE;
|
||||
DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_DRAW\n");
|
||||
|
||||
ConsoleDraw = (PCONSOLE_DRAW)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||
/* FIXME: remove */ { ConsoleDraw->X++; ConsoleDraw->CursorX++; }
|
||||
/* FIXME: remove */ { ConsoleDraw->Y++; ConsoleDraw->CursorY++; }
|
||||
DPRINT1("%lu %lu %lu %lu\n",
|
||||
ConsoleDraw->X, ConsoleDraw->Y,
|
||||
ConsoleDraw->SizeX, ConsoleDraw->SizeY);
|
||||
ASSERT(ConsoleDraw->X >= 1);
|
||||
ASSERT(ConsoleDraw->Y >= 1);
|
||||
ASSERT(ConsoleDraw->X <= DeviceExtension->Columns);
|
||||
ASSERT(ConsoleDraw->Y <= DeviceExtension->Rows);
|
||||
ASSERT(ConsoleDraw->X + ConsoleDraw->SizeX >= 1);
|
||||
ASSERT(ConsoleDraw->Y + ConsoleDraw->SizeY >= 1);
|
||||
ASSERT(ConsoleDraw->X + ConsoleDraw->SizeX - 1 <= DeviceExtension->Columns);
|
||||
ASSERT(ConsoleDraw->Y + ConsoleDraw->SizeY - 1 <= DeviceExtension->Rows);
|
||||
ASSERT(ConsoleDraw->CursorX >= 1);
|
||||
ASSERT(ConsoleDraw->CursorY >= 1);
|
||||
ASSERT(ConsoleDraw->CursorX <= DeviceExtension->Columns);
|
||||
ASSERT(ConsoleDraw->CursorY <= DeviceExtension->Rows);
|
||||
|
||||
#if 0
|
||||
if (ConsoleDraw->X == 1
|
||||
&& ConsoleDraw->Y == 1
|
||||
&& ConsoleDraw->SizeX == DeviceExtension->Columns
|
||||
&& ConsoleDraw->SizeY == DeviceExtension->Rows)
|
||||
{
|
||||
CHECKPOINT1;
|
||||
/* search if we need to clear all screen */
|
||||
DoOptimization = TRUE;
|
||||
Video = (PUCHAR)(ConsoleDraw + 1);
|
||||
x = 0;
|
||||
while (DoOptimization && x < DeviceExtension->Columns * DeviceExtension->Rows)
|
||||
{
|
||||
if (Video[x++] != ' ')
|
||||
{
|
||||
CHECKPOINT1;
|
||||
DoOptimization = FALSE;
|
||||
}
|
||||
/*if (Video[x++] != DeviceExtension->CharAttribute) DoOptimization = FALSE; */
|
||||
}
|
||||
if (DoOptimization)
|
||||
{
|
||||
CHECKPOINT1;
|
||||
AddToSendBuffer(DeviceExtension, 4, ESC, '[', '2', 'J');
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* add here more optimizations if needed */
|
||||
|
||||
if (!DoOptimization)
|
||||
{
|
||||
for (y = 0; y < ConsoleDraw->SizeY; y++)
|
||||
{
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[',
|
||||
-(int)(ConsoleDraw->Y + y), ';',
|
||||
-(int)(ConsoleDraw->X), 'H');
|
||||
Video = (PUCHAR)(ConsoleDraw + 1);
|
||||
Video = &Video[((ConsoleDraw->Y + y) * /*DeviceExtension->Columns +*/ ConsoleDraw->X) * 2];
|
||||
for (x = 0; x < ConsoleDraw->SizeX; x++)
|
||||
{
|
||||
AddToSendBuffer(DeviceExtension, 1, Video[x * 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeviceExtension->LogicalOffset = (
|
||||
(ConsoleDraw->CursorY-1) * DeviceExtension->Columns +
|
||||
(ConsoleDraw->CursorX-1)) * 2;
|
||||
AddToSendBuffer(DeviceExtension, 6, ESC, '[',
|
||||
-(int)(ConsoleDraw->CursorY), ';',
|
||||
-(int)(ConsoleDraw->CursorX), 'H');
|
||||
|
||||
/* flush buffer */
|
||||
AddToSendBuffer(DeviceExtension, 0);
|
||||
|
||||
Irp->IoStatus.Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
|
||||
Stack->Parameters.DeviceIoControl.IoControlCode);
|
||||
/* Call lower driver */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->Common.LowerDevice, Irp);
|
||||
}
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Don't call blue (if any), as we encountered an error */
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call lower driver */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->Common.LowerDevice, Irp);
|
||||
}
|
||||
}
|
54
rosapps/imagesoft/about.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <precomp.h>
|
||||
|
||||
INT_PTR CALLBACK
|
||||
AboutDialogProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
HWND hLicenseEditWnd;
|
||||
HICON hIcon = NULL;
|
||||
TCHAR strLicense[700];
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
|
||||
hIcon = (HICON) LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDI_IMAGESOFTICON),
|
||||
IMAGE_ICON,
|
||||
16,
|
||||
16,
|
||||
0);
|
||||
|
||||
SendMessage(hDlg,
|
||||
WM_SETICON,
|
||||
ICON_SMALL,
|
||||
(LPARAM)hIcon);
|
||||
|
||||
hLicenseEditWnd = GetDlgItem(hDlg,
|
||||
IDC_LICENSE_EDIT);
|
||||
|
||||
LoadString(hInstance,
|
||||
IDS_LICENSE,
|
||||
strLicense,
|
||||
sizeof(strLicense) / sizeof(TCHAR));
|
||||
|
||||
SetWindowText(hLicenseEditWnd,
|
||||
strLicense);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
|
||||
{
|
||||
DestroyIcon(hIcon);
|
||||
EndDialog(hDlg,
|
||||
LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
525
rosapps/imagesoft/adjust.c
Normal file
|
@ -0,0 +1,525 @@
|
|||
#include <precomp.h>
|
||||
|
||||
|
||||
BOOL
|
||||
DisplayBlackAndWhite(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
BITMAP bitmap;
|
||||
BOOL bRes;
|
||||
DWORD Count = 0;
|
||||
INT i, j;
|
||||
PBYTE pBits;
|
||||
RECT rc;
|
||||
|
||||
GetObject(hBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
/* Bitmap header */
|
||||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
bi.bmiHeader.biWidth = bitmap.bmWidth;
|
||||
bi.bmiHeader.biHeight = bitmap.bmHeight;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
/* Buffer */
|
||||
pBits = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
if (!pBits)
|
||||
return FALSE;
|
||||
|
||||
/* get the bits from the original bitmap */
|
||||
bRes = GetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bitmap.bmHeight,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
for (i = 0; i < bitmap.bmHeight; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap.bmWidth; j++)
|
||||
{
|
||||
DWORD Val = 0;
|
||||
INT b, g, r;
|
||||
|
||||
CopyMemory(&Val,
|
||||
&pBits[Count],
|
||||
4);
|
||||
|
||||
/* Get pixels in reverse order */
|
||||
b = GetRValue(Val);
|
||||
g = GetGValue(Val);
|
||||
r = GetBValue(Val);
|
||||
|
||||
/* get the average color value */
|
||||
Val = (r + g + b) / 3;
|
||||
|
||||
/* assign to RGB color */
|
||||
Val = RGB(Val, Val, Val);
|
||||
CopyMemory(&pBits[Count],
|
||||
&Val,
|
||||
4);
|
||||
|
||||
Count+=4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the new pixel bits */
|
||||
SetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bRes,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBits);
|
||||
|
||||
GetClientRect(hwnd,
|
||||
&rc);
|
||||
|
||||
InvalidateRect(hwnd,
|
||||
&rc,
|
||||
FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
DisplayInvertedColors(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
BITMAP bitmap;
|
||||
BOOL bRes;
|
||||
DWORD Count = 0;
|
||||
INT i, j;
|
||||
PBYTE pBits;
|
||||
RECT rc;
|
||||
|
||||
GetObject(hBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
/* Bitmap header */
|
||||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
bi.bmiHeader.biWidth = bitmap.bmWidth;
|
||||
bi.bmiHeader.biHeight = bitmap.bmHeight;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
/* Buffer */
|
||||
pBits = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
if (!pBits)
|
||||
return FALSE;
|
||||
|
||||
/* get the bits from the original bitmap */
|
||||
bRes = GetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bitmap.bmHeight,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
for (i = 0; i < bitmap.bmHeight; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap.bmWidth; j++)
|
||||
{
|
||||
DWORD Val = 0;
|
||||
INT b, g, r;
|
||||
|
||||
CopyMemory(&Val,
|
||||
&pBits[Count],
|
||||
4);
|
||||
|
||||
b = 255 - GetRValue(Val);
|
||||
g = 255 - GetGValue(Val);
|
||||
r = 255 - GetBValue(Val);
|
||||
|
||||
Val = RGB(b, g, r);
|
||||
|
||||
CopyMemory(&pBits[Count],
|
||||
&Val,
|
||||
4);
|
||||
|
||||
Count+=4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the new pixel bits */
|
||||
SetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bRes,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBits);
|
||||
|
||||
GetClientRect(hwnd,
|
||||
&rc);
|
||||
|
||||
InvalidateRect(hwnd,
|
||||
&rc,
|
||||
FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL
|
||||
DisplayBlur(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
BITMAP bitmap;
|
||||
BOOL bRes;
|
||||
DWORD Count = 0;
|
||||
INT i, j;
|
||||
PBYTE pBits, pBitsTemp;
|
||||
RECT rc;
|
||||
|
||||
GetObject(hBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
/* Bitmap header */
|
||||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
bi.bmiHeader.biWidth = bitmap.bmWidth;
|
||||
bi.bmiHeader.biHeight = bitmap.bmHeight;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
/* Buffer */
|
||||
pBits = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
pBitsTemp = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
if (!pBits || !pBitsTemp)
|
||||
return FALSE;
|
||||
|
||||
/* get the bits from the original bitmap */
|
||||
bRes = GetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bitmap.bmHeight,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
for (i = 0; i < bitmap.bmHeight; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap.bmWidth; j++)
|
||||
{
|
||||
LONG Val = 0;
|
||||
INT b, g, r;
|
||||
INT c1, c2, c3, c4, c5;
|
||||
|
||||
CopyMemory(&Val,
|
||||
&pBits[Count],
|
||||
4);
|
||||
|
||||
b = GetRValue(Val);
|
||||
g = GetGValue(Val);
|
||||
r = GetBValue(Val);
|
||||
|
||||
c1 = r;
|
||||
/* Red */
|
||||
if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
|
||||
(Count > (bitmap.bmWidth * 4lu)))
|
||||
{
|
||||
CopyMemory(&Val, &pBits[Count - (bitmap.bmWidth * 4)], 4);
|
||||
c2 = GetBValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count + 4], 4);
|
||||
c3 = GetBValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4))], 4);
|
||||
c4 = GetBValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count - 4], 4);
|
||||
c5 = GetBValue(Val);
|
||||
|
||||
r = (c1 + c2 + c3 + c4 + c5) / 5;
|
||||
}
|
||||
|
||||
/* Green */
|
||||
c1 = g;
|
||||
if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
|
||||
(Count > (bitmap.bmWidth * 4lu)))
|
||||
{
|
||||
CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4lu))], 4);
|
||||
c2 = GetGValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count + 4], 4);
|
||||
c3 = GetGValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4lu))], 4);
|
||||
c4 = GetGValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count-4], 4);
|
||||
c5 = GetGValue(Val);
|
||||
|
||||
g = (c1 + c2 + c3 + c4 + c5) / 5;
|
||||
}
|
||||
|
||||
/* Blue */
|
||||
c1 = b;
|
||||
if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
|
||||
(Count > (bitmap.bmWidth * 4lu)))
|
||||
{
|
||||
CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
|
||||
c2 = GetRValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count + 4], 4);
|
||||
c3 = GetRValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
|
||||
c4 = GetRValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count-4], 4);
|
||||
c5 = GetRValue(Val);
|
||||
|
||||
b = (c1 + c2 + c3 + c4 + c5) / 5;
|
||||
}
|
||||
|
||||
Val = RGB(b, g, r);
|
||||
|
||||
CopyMemory(&pBitsTemp[Count],
|
||||
&Val,
|
||||
4);
|
||||
|
||||
Count+=4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the new pixel bits */
|
||||
SetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bRes,
|
||||
pBitsTemp,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBits);
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBitsTemp);
|
||||
|
||||
GetClientRect(hwnd,
|
||||
&rc);
|
||||
|
||||
InvalidateRect(hwnd,
|
||||
&rc,
|
||||
FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL
|
||||
DisplaySharpness(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
BITMAP bitmap;
|
||||
BOOL bRes;
|
||||
DWORD Count = 0;
|
||||
INT i, j;
|
||||
PBYTE pBits, pBitsTemp;
|
||||
RECT rc;
|
||||
|
||||
GetObject(hBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
/* Bitmap header */
|
||||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
bi.bmiHeader.biWidth = bitmap.bmWidth;
|
||||
bi.bmiHeader.biHeight = bitmap.bmHeight;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
/* Buffer */
|
||||
pBits = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
pBitsTemp = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
if (!pBits || !pBitsTemp)
|
||||
return FALSE;
|
||||
|
||||
/* get the bits from the original bitmap */
|
||||
bRes = GetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bitmap.bmHeight,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
for (i = 0; i < bitmap.bmHeight; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap.bmWidth; j++)
|
||||
{
|
||||
LONG Val = 0;
|
||||
INT b, g, r;
|
||||
INT c1, c2, c3, c4, c5;
|
||||
|
||||
CopyMemory(&Val,
|
||||
&pBits[Count],
|
||||
4);
|
||||
|
||||
b = GetRValue(Val);
|
||||
g = GetGValue(Val);
|
||||
r = GetBValue(Val);
|
||||
|
||||
c1 = r;
|
||||
/* Red */
|
||||
if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
|
||||
(Count > (bitmap.bmWidth * 4lu)))
|
||||
{
|
||||
CopyMemory(&Val, &pBits[Count - (bitmap.bmWidth * 4l)], 4);
|
||||
c2 = GetBValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count + 4], 4);
|
||||
c3 = GetBValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
|
||||
c4 = GetBValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count - 4], 4);
|
||||
c5 = GetBValue(Val);
|
||||
|
||||
r = (c1 * 5) - (c2 + c3 + c4 + c5);
|
||||
}
|
||||
|
||||
/* Green */
|
||||
c1 = g;
|
||||
if ((Count < ((bitmap.bmHeight - 1)* bitmap.bmWidth * 4lu)) &&
|
||||
(Count > (bitmap.bmWidth * 4lu)))
|
||||
{
|
||||
CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
|
||||
c2 = GetGValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count + 4], 4);
|
||||
c3 = GetGValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
|
||||
c4 = GetGValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count - 4], 4);
|
||||
c5 = GetGValue(Val);
|
||||
|
||||
g = (c1 * 5) - (c2 + c3 + c4 + c5);
|
||||
}
|
||||
|
||||
/* Blue */
|
||||
c1 = b;
|
||||
if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
|
||||
(Count > (bitmap.bmWidth * 4lu)))
|
||||
{
|
||||
CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
|
||||
c2 = GetRValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count + 4], 4);
|
||||
c3 = GetRValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[(Count+(bitmap.bmWidth * 4l))], 4);
|
||||
c4 = GetRValue(Val);
|
||||
|
||||
CopyMemory(&Val, &pBits[Count - 4], 4);
|
||||
c5 = GetRValue(Val);
|
||||
|
||||
b = (c1 * 5) - (c2 + c3 + c4 + c5);
|
||||
}
|
||||
|
||||
/* Red */
|
||||
if (r > 255) r = 255;
|
||||
if (r < 0) r = 0;
|
||||
|
||||
/* Green */
|
||||
if (g > 255) g = 255;
|
||||
if (g < 0)g = 0;
|
||||
|
||||
/* Blue */
|
||||
if (b > 255) b = 255;
|
||||
if (b < 0) b = 0;
|
||||
|
||||
Val = RGB(b, g, r);
|
||||
|
||||
CopyMemory(&pBitsTemp[Count],
|
||||
&Val,
|
||||
4);
|
||||
|
||||
Count+=4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the new pixel bits */
|
||||
SetDIBits(hdcMem,
|
||||
hBitmap,
|
||||
0,
|
||||
bRes,
|
||||
pBitsTemp,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBits);
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBitsTemp);
|
||||
|
||||
GetClientRect(hwnd,
|
||||
&rc);
|
||||
|
||||
InvalidateRect(hwnd,
|
||||
&rc,
|
||||
FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
379
rosapps/imagesoft/brightness.c
Normal file
|
@ -0,0 +1,379 @@
|
|||
#include "precomp.h"
|
||||
|
||||
#define BASECOLOUR 100
|
||||
|
||||
|
||||
VOID
|
||||
AdjustBrightness(HBITMAP hOrigBitmap,
|
||||
HBITMAP hNewBitmap,
|
||||
HWND hwnd,
|
||||
HDC hdcMem,
|
||||
INT RedVal,
|
||||
INT GreenVal,
|
||||
INT BlueVal)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
BITMAP bitmap;
|
||||
BOOL bRes;
|
||||
DWORD Count = 0;
|
||||
INT i, j;
|
||||
PBYTE pBits;
|
||||
RECT rc;
|
||||
|
||||
GetObject(hNewBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
/* Bitmap header */
|
||||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
bi.bmiHeader.biWidth = bitmap.bmWidth;
|
||||
bi.bmiHeader.biHeight = bitmap.bmHeight;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
/* Buffer */
|
||||
pBits = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
if (!pBits)
|
||||
return;
|
||||
|
||||
/* get the bits from the original bitmap */
|
||||
bRes = GetDIBits(hdcMem,
|
||||
hOrigBitmap,
|
||||
0,
|
||||
bitmap.bmHeight,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
for (i = 0; i < bitmap.bmHeight; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap.bmWidth; j++)
|
||||
{
|
||||
DWORD Val = 0;
|
||||
INT b, g, r;
|
||||
|
||||
CopyMemory(&Val,
|
||||
&pBits[Count],
|
||||
4);
|
||||
|
||||
/* Get pixels in reverse order */
|
||||
b = GetRValue(Val);
|
||||
g = GetGValue(Val);
|
||||
r = GetBValue(Val);
|
||||
|
||||
/* Red */
|
||||
r += RedVal;
|
||||
if (r > 255) r = 255;
|
||||
else if (r < 0) r = 0;
|
||||
|
||||
/* Green */
|
||||
g += GreenVal;
|
||||
if (g > 255) g = 255;
|
||||
else if (g < 0) g = 0;
|
||||
|
||||
/* Blue */
|
||||
b += BlueVal;
|
||||
if (b > 255) b = 255;
|
||||
else if (b < 0) b = 0;
|
||||
|
||||
/* Store in reverse order */
|
||||
Val = RGB(b, g, r);
|
||||
CopyMemory(&pBits[Count],
|
||||
&Val,
|
||||
4);
|
||||
|
||||
/* RGB color take 4 bytes.The high-order byte must be zero */
|
||||
Count += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the new pixel bits */
|
||||
SetDIBits(hdcMem,
|
||||
hNewBitmap,
|
||||
0,
|
||||
bRes,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBits);
|
||||
|
||||
GetClientRect(hwnd,
|
||||
&rc);
|
||||
|
||||
InvalidateRect(hwnd,
|
||||
&rc,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
static PIMAGEADJUST
|
||||
Bri_OnInitDialog(PIMAGEADJUST pImgAdj,
|
||||
HWND hDlg,
|
||||
LPARAM lParam)
|
||||
{
|
||||
pImgAdj = (IMAGEADJUST*) HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
sizeof(IMAGEADJUST));
|
||||
if (!pImgAdj)
|
||||
return NULL;
|
||||
|
||||
|
||||
pImgAdj->Info = (PMAIN_WND_INFO)lParam;
|
||||
if (!pImgAdj->Info->ImageEditors)
|
||||
goto fail;
|
||||
|
||||
|
||||
pImgAdj->hPicPrev = GetDlgItem(hDlg, IDC_PICPREVIEW);
|
||||
GetClientRect(pImgAdj->hPicPrev,
|
||||
&pImgAdj->ImageRect);
|
||||
|
||||
/* Make a static copy of the main image */
|
||||
pImgAdj->hBitmap = (HBITMAP) CopyImage(pImgAdj->Info->ImageEditors->hBitmap,
|
||||
IMAGE_BITMAP,
|
||||
pImgAdj->ImageRect.right,
|
||||
pImgAdj->ImageRect.bottom,
|
||||
LR_CREATEDIBSECTION);
|
||||
if (!pImgAdj->hBitmap)
|
||||
goto fail;
|
||||
|
||||
/* Make a copy which will be updated */
|
||||
pImgAdj->hPreviewBitmap = (HBITMAP) CopyImage(pImgAdj->Info->ImageEditors->hBitmap,
|
||||
IMAGE_BITMAP,
|
||||
pImgAdj->ImageRect.right,
|
||||
pImgAdj->ImageRect.bottom,
|
||||
LR_CREATEDIBSECTION);
|
||||
if (!pImgAdj->hPreviewBitmap)
|
||||
goto fail;
|
||||
|
||||
|
||||
pImgAdj->RedVal = pImgAdj->BlueVal = pImgAdj->GreenVal = 0;
|
||||
|
||||
/* setup dialog */
|
||||
SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_FULL,
|
||||
BM_SETCHECK,
|
||||
BST_CHECKED,
|
||||
0);
|
||||
SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_TRACKBAR,
|
||||
TBM_SETRANGE,
|
||||
TRUE,
|
||||
(LPARAM)MAKELONG(0, 200));
|
||||
SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_TRACKBAR,
|
||||
TBM_SETPOS,
|
||||
TRUE,
|
||||
(LPARAM)BASECOLOUR);
|
||||
SetDlgItemText(hDlg,
|
||||
IDC_BRI_EDIT,
|
||||
_T("100"));
|
||||
|
||||
return pImgAdj;
|
||||
|
||||
fail:
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pImgAdj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
Bri_OnDrawItem(PIMAGEADJUST pImgAdj,
|
||||
LPARAM lParam)
|
||||
{
|
||||
LPDRAWITEMSTRUCT lpDrawItem;
|
||||
HDC hdcMem;
|
||||
|
||||
lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
|
||||
|
||||
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
|
||||
|
||||
if(lpDrawItem->CtlID == IDC_PICPREVIEW)
|
||||
{
|
||||
SelectObject(hdcMem,
|
||||
pImgAdj->hPreviewBitmap);
|
||||
|
||||
BitBlt(lpDrawItem->hDC,
|
||||
pImgAdj->ImageRect.left,
|
||||
pImgAdj->ImageRect.top,
|
||||
pImgAdj->ImageRect.right,
|
||||
pImgAdj->ImageRect.bottom,
|
||||
hdcMem,
|
||||
0,
|
||||
0,
|
||||
SRCCOPY);
|
||||
|
||||
DeleteDC(hdcMem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
Bri_OnTrackBar(PIMAGEADJUST pImgAdj,
|
||||
HWND hDlg)
|
||||
{
|
||||
HDC hdcMem;
|
||||
DWORD TrackPos;
|
||||
|
||||
TrackPos = (DWORD)SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_TRACKBAR,
|
||||
TBM_GETPOS,
|
||||
0,
|
||||
0);
|
||||
|
||||
SetDlgItemInt(hDlg,
|
||||
IDC_BRI_EDIT,
|
||||
TrackPos,
|
||||
FALSE);
|
||||
|
||||
if (IsDlgButtonChecked(hDlg, IDC_BRI_FULL) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->RedVal = pImgAdj->GreenVal = pImgAdj->BlueVal = TrackPos - BASECOLOUR;
|
||||
}
|
||||
else if (IsDlgButtonChecked(hDlg, IDC_BRI_RED) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->RedVal = TrackPos - BASECOLOUR;
|
||||
}
|
||||
else if (IsDlgButtonChecked(hDlg, IDC_BRI_GREEN) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->GreenVal = TrackPos - BASECOLOUR;
|
||||
}
|
||||
else if (IsDlgButtonChecked(hDlg, IDC_BRI_BLUE) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->BlueVal = TrackPos - BASECOLOUR;
|
||||
}
|
||||
|
||||
hdcMem = GetDC(pImgAdj->hPicPrev);
|
||||
|
||||
AdjustBrightness(pImgAdj->hBitmap,
|
||||
pImgAdj->hPreviewBitmap,
|
||||
pImgAdj->hPicPrev,
|
||||
hdcMem,
|
||||
pImgAdj->RedVal,
|
||||
pImgAdj->GreenVal,
|
||||
pImgAdj->BlueVal);
|
||||
|
||||
ReleaseDC(pImgAdj->hPicPrev, hdcMem);
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
Bri_OnCommand(PIMAGEADJUST pImgAdj,
|
||||
HWND hDlg,
|
||||
UINT uID)
|
||||
{
|
||||
switch (uID)
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HDC hdcMem;
|
||||
|
||||
hdcMem = GetDC(pImgAdj->Info->ImageEditors->hSelf);
|
||||
|
||||
AdjustBrightness(pImgAdj->Info->ImageEditors->hBitmap,
|
||||
pImgAdj->Info->ImageEditors->hBitmap,
|
||||
pImgAdj->Info->ImageEditors->hSelf,
|
||||
hdcMem,
|
||||
pImgAdj->RedVal,
|
||||
pImgAdj->GreenVal,
|
||||
pImgAdj->BlueVal);
|
||||
|
||||
ReleaseDC(pImgAdj->Info->ImageEditors->hSelf,
|
||||
hdcMem);
|
||||
|
||||
EndDialog(hDlg,
|
||||
uID);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDCANCEL:
|
||||
{
|
||||
EndDialog(hDlg,
|
||||
uID);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
INT_PTR CALLBACK
|
||||
BrightnessProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
static PIMAGEADJUST pImgAdj = NULL;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pImgAdj = Bri_OnInitDialog(pImgAdj,
|
||||
hDlg,
|
||||
lParam);
|
||||
if (!pImgAdj)
|
||||
{
|
||||
EndDialog(hDlg, -1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
Bri_OnDrawItem(pImgAdj,
|
||||
lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
if (LOWORD(wParam) == TB_THUMBTRACK ||
|
||||
LOWORD(wParam) == TB_ENDTRACK)
|
||||
{
|
||||
Bri_OnTrackBar(pImgAdj,
|
||||
hDlg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
return Bri_OnCommand(pImgAdj,
|
||||
hDlg,
|
||||
LOWORD(wParam));
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
if (pImgAdj)
|
||||
{
|
||||
if (pImgAdj->hBitmap)
|
||||
DeleteObject(pImgAdj->hBitmap);
|
||||
if (pImgAdj->hPreviewBitmap)
|
||||
DeleteObject(pImgAdj->hPreviewBitmap);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pImgAdj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
380
rosapps/imagesoft/contrast.c
Normal file
|
@ -0,0 +1,380 @@
|
|||
#include "precomp.h"
|
||||
|
||||
#define BASECOLOUR 100
|
||||
|
||||
|
||||
VOID
|
||||
AdjustContrast(HBITMAP hOrigBitmap,
|
||||
HBITMAP hNewBitmap,
|
||||
HWND hwnd,
|
||||
HDC hdcMem,
|
||||
INT RedVal,
|
||||
INT GreenVal,
|
||||
INT BlueVal)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
BITMAP bitmap;
|
||||
BOOL bRes;
|
||||
DWORD Count = 0;
|
||||
INT i, j;
|
||||
PBYTE pBits;
|
||||
RECT rc;
|
||||
|
||||
GetObject(hNewBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
/* Bitmap header */
|
||||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
bi.bmiHeader.biWidth = bitmap.bmWidth;
|
||||
bi.bmiHeader.biHeight = bitmap.bmHeight;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
/* Buffer */
|
||||
pBits = (PBYTE)HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
bitmap.bmWidth * bitmap.bmHeight * 4);
|
||||
if (!pBits)
|
||||
return;
|
||||
|
||||
/* get the bits from the original bitmap */
|
||||
bRes = GetDIBits(hdcMem,
|
||||
hOrigBitmap,
|
||||
0,
|
||||
bitmap.bmHeight,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
for (i = 0; i < bitmap.bmHeight; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap.bmWidth; j++)
|
||||
{
|
||||
DWORD Val = 0;
|
||||
INT b, g, r;
|
||||
|
||||
CopyMemory(&Val,
|
||||
&pBits[Count],
|
||||
4);
|
||||
|
||||
/* Get pixels in reverse order */
|
||||
b = GetRValue(Val);
|
||||
g = GetGValue(Val);
|
||||
r = GetBValue(Val);
|
||||
|
||||
r = ((r - 128) * RedVal) / 100 + 128;
|
||||
g = ((g - 128) * GreenVal) / 100 + 128;
|
||||
b = ((b - 128) * BlueVal) / 100 + 128;
|
||||
|
||||
/* Red */
|
||||
if (r > 255) r = 255;
|
||||
else if (r < 0) r = 0;
|
||||
|
||||
/* Green */
|
||||
if (g > 255) g = 255;
|
||||
else if (g < 0) g = 0;
|
||||
|
||||
/* Blue */
|
||||
if (b > 255) b = 255;
|
||||
else if (b < 0) b = 0;
|
||||
|
||||
/* Store in reverse order */
|
||||
Val = RGB(b, g, r);
|
||||
CopyMemory(&pBits[Count],
|
||||
&Val,
|
||||
4);
|
||||
|
||||
/* RGB color take 4 bytes.The high-order byte must be zero */
|
||||
Count += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the new pixel bits */
|
||||
SetDIBits(hdcMem,
|
||||
hNewBitmap,
|
||||
0,
|
||||
bRes,
|
||||
pBits,
|
||||
&bi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pBits);
|
||||
|
||||
GetClientRect(hwnd,
|
||||
&rc);
|
||||
|
||||
InvalidateRect(hwnd,
|
||||
&rc,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
static PIMAGEADJUST
|
||||
Cont_OnInitDialog(PIMAGEADJUST pImgAdj,
|
||||
HWND hDlg,
|
||||
LPARAM lParam)
|
||||
{
|
||||
pImgAdj = (IMAGEADJUST*) HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
sizeof(IMAGEADJUST));
|
||||
if (!pImgAdj)
|
||||
return NULL;
|
||||
|
||||
|
||||
pImgAdj->Info = (PMAIN_WND_INFO)lParam;
|
||||
if (!pImgAdj->Info->ImageEditors)
|
||||
goto fail;
|
||||
|
||||
|
||||
pImgAdj->hPicPrev = GetDlgItem(hDlg, IDC_PICPREVIEW);
|
||||
GetClientRect(pImgAdj->hPicPrev,
|
||||
&pImgAdj->ImageRect);
|
||||
|
||||
/* Make a static copy of the main image */
|
||||
pImgAdj->hBitmap = (HBITMAP) CopyImage(pImgAdj->Info->ImageEditors->hBitmap,
|
||||
IMAGE_BITMAP,
|
||||
pImgAdj->ImageRect.right,
|
||||
pImgAdj->ImageRect.bottom,
|
||||
LR_CREATEDIBSECTION);
|
||||
if (!pImgAdj->hBitmap)
|
||||
goto fail;
|
||||
|
||||
/* Make a copy which will be updated */
|
||||
pImgAdj->hPreviewBitmap = (HBITMAP) CopyImage(pImgAdj->Info->ImageEditors->hBitmap,
|
||||
IMAGE_BITMAP,
|
||||
pImgAdj->ImageRect.right,
|
||||
pImgAdj->ImageRect.bottom,
|
||||
LR_CREATEDIBSECTION);
|
||||
if (!pImgAdj->hPreviewBitmap)
|
||||
goto fail;
|
||||
|
||||
|
||||
pImgAdj->RedVal = pImgAdj->BlueVal = pImgAdj->GreenVal = 100;
|
||||
|
||||
/* setup dialog */
|
||||
SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_FULL,
|
||||
BM_SETCHECK,
|
||||
BST_CHECKED,
|
||||
0);
|
||||
SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_TRACKBAR,
|
||||
TBM_SETRANGE,
|
||||
TRUE,
|
||||
(LPARAM)MAKELONG(0, 200));
|
||||
SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_TRACKBAR,
|
||||
TBM_SETPOS,
|
||||
TRUE,
|
||||
(LPARAM)BASECOLOUR);
|
||||
SetDlgItemText(hDlg,
|
||||
IDC_BRI_EDIT,
|
||||
_T("100"));
|
||||
|
||||
return pImgAdj;
|
||||
|
||||
fail:
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pImgAdj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
Cont_OnDrawItem(PIMAGEADJUST pImgAdj,
|
||||
LPARAM lParam)
|
||||
{
|
||||
LPDRAWITEMSTRUCT lpDrawItem;
|
||||
HDC hdcMem;
|
||||
|
||||
lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
|
||||
|
||||
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
|
||||
|
||||
if(lpDrawItem->CtlID == IDC_PICPREVIEW)
|
||||
{
|
||||
SelectObject(hdcMem,
|
||||
pImgAdj->hPreviewBitmap);
|
||||
|
||||
BitBlt(lpDrawItem->hDC,
|
||||
pImgAdj->ImageRect.left,
|
||||
pImgAdj->ImageRect.top,
|
||||
pImgAdj->ImageRect.right,
|
||||
pImgAdj->ImageRect.bottom,
|
||||
hdcMem,
|
||||
0,
|
||||
0,
|
||||
SRCCOPY);
|
||||
|
||||
DeleteDC(hdcMem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
Cont_OnTrackBar(PIMAGEADJUST pImgAdj,
|
||||
HWND hDlg)
|
||||
{
|
||||
HDC hdcMem;
|
||||
DWORD TrackPos;
|
||||
|
||||
TrackPos = (DWORD)SendDlgItemMessage(hDlg,
|
||||
IDC_BRI_TRACKBAR,
|
||||
TBM_GETPOS,
|
||||
0,
|
||||
0);
|
||||
|
||||
SetDlgItemInt(hDlg,
|
||||
IDC_BRI_EDIT,
|
||||
TrackPos,
|
||||
FALSE);
|
||||
|
||||
if (IsDlgButtonChecked(hDlg, IDC_BRI_FULL) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->RedVal = pImgAdj->GreenVal = pImgAdj->BlueVal = TrackPos - BASECOLOUR + 100;
|
||||
}
|
||||
else if (IsDlgButtonChecked(hDlg, IDC_BRI_RED) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->RedVal = TrackPos - BASECOLOUR + 100;
|
||||
}
|
||||
else if (IsDlgButtonChecked(hDlg, IDC_BRI_GREEN) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->GreenVal = TrackPos - BASECOLOUR + 100;
|
||||
}
|
||||
else if (IsDlgButtonChecked(hDlg, IDC_BRI_BLUE) == BST_CHECKED)
|
||||
{
|
||||
pImgAdj->BlueVal = TrackPos - BASECOLOUR + 100;
|
||||
}
|
||||
|
||||
hdcMem = GetDC(pImgAdj->hPicPrev);
|
||||
|
||||
AdjustContrast(pImgAdj->hBitmap,
|
||||
pImgAdj->hPreviewBitmap,
|
||||
pImgAdj->hPicPrev,
|
||||
hdcMem,
|
||||
pImgAdj->RedVal,
|
||||
pImgAdj->GreenVal,
|
||||
pImgAdj->BlueVal);
|
||||
|
||||
ReleaseDC(pImgAdj->hPicPrev, hdcMem);
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
Cont_OnCommand(PIMAGEADJUST pImgAdj,
|
||||
HWND hDlg,
|
||||
UINT uID)
|
||||
{
|
||||
switch (uID)
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HDC hdcMem;
|
||||
|
||||
hdcMem = GetDC(pImgAdj->Info->ImageEditors->hSelf);
|
||||
|
||||
AdjustContrast(pImgAdj->Info->ImageEditors->hBitmap,
|
||||
pImgAdj->Info->ImageEditors->hBitmap,
|
||||
pImgAdj->Info->ImageEditors->hSelf,
|
||||
hdcMem,
|
||||
pImgAdj->RedVal,
|
||||
pImgAdj->GreenVal,
|
||||
pImgAdj->BlueVal);
|
||||
|
||||
ReleaseDC(pImgAdj->Info->ImageEditors->hSelf,
|
||||
hdcMem);
|
||||
|
||||
EndDialog(hDlg,
|
||||
uID);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDCANCEL:
|
||||
{
|
||||
EndDialog(hDlg,
|
||||
uID);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
INT_PTR CALLBACK
|
||||
ContrastProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
static PIMAGEADJUST pImgAdj = NULL;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pImgAdj = Cont_OnInitDialog(pImgAdj,
|
||||
hDlg,
|
||||
lParam);
|
||||
if (!pImgAdj)
|
||||
{
|
||||
EndDialog(hDlg, -1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
Cont_OnDrawItem(pImgAdj,
|
||||
lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
if (LOWORD(wParam) == TB_THUMBTRACK ||
|
||||
LOWORD(wParam) == TB_ENDTRACK)
|
||||
{
|
||||
Cont_OnTrackBar(pImgAdj,
|
||||
hDlg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
return Cont_OnCommand(pImgAdj,
|
||||
hDlg,
|
||||
LOWORD(wParam));
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
if (pImgAdj)
|
||||
{
|
||||
if (pImgAdj->hBitmap)
|
||||
DeleteObject(pImgAdj->hBitmap);
|
||||
if (pImgAdj->hPreviewBitmap)
|
||||
DeleteObject(pImgAdj->hPreviewBitmap);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
pImgAdj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
213
rosapps/imagesoft/custcombo.c
Normal file
|
@ -0,0 +1,213 @@
|
|||
#include <precomp.h>
|
||||
|
||||
|
||||
LRESULT WINAPI
|
||||
FlatComboProc(HWND hwnd,
|
||||
UINT msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT rect, rect2;
|
||||
POINT pt;
|
||||
|
||||
WNDPROC OldComboProc = (WNDPROC)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
|
||||
static BOOL fMouseDown = FALSE;
|
||||
static BOOL fButtonDown = FALSE;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
if(wParam == 0) hdc = BeginPaint(hwnd, &ps);
|
||||
else hdc = (HDC)wParam;
|
||||
|
||||
/* mask off the borders and draw ComboBox normally */
|
||||
GetClientRect(hwnd, &rect);
|
||||
|
||||
InflateRect(&rect,
|
||||
-GetSystemMetrics(SM_CXEDGE)*2,
|
||||
-GetSystemMetrics(SM_CYEDGE)*2);
|
||||
|
||||
rect.right -= GetSystemMetrics(SM_CXVSCROLL);
|
||||
|
||||
IntersectClipRect(hdc,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right,
|
||||
rect.bottom);
|
||||
|
||||
/* Draw the ComboBox */
|
||||
CallWindowProc(OldComboProc,
|
||||
hwnd,
|
||||
msg,
|
||||
(WPARAM)hdc,
|
||||
lParam);
|
||||
|
||||
/* Now mask off inside and draw the borders */
|
||||
SelectClipRgn(hdc,
|
||||
NULL);
|
||||
rect.right += GetSystemMetrics(SM_CXVSCROLL);
|
||||
|
||||
ExcludeClipRect(hdc,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right,
|
||||
rect.bottom);
|
||||
|
||||
/* draw borders */
|
||||
GetClientRect(hwnd,
|
||||
&rect2);
|
||||
FillRect(hdc,
|
||||
&rect2,
|
||||
//CreateSolidBrush(RGB(0,0,0)));
|
||||
GetSysColorBrush(COLOR_3DFACE));
|
||||
|
||||
/* now draw the button */
|
||||
SelectClipRgn(hdc,
|
||||
NULL);
|
||||
rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
|
||||
|
||||
if(fButtonDown)
|
||||
{
|
||||
HBRUSH oldBrush;
|
||||
HPEN oldPen;
|
||||
POINT pt[3];
|
||||
|
||||
FillRect(hdc, &rect, CreateSolidBrush(RGB(182,189,210)));
|
||||
rect.top -= 1;
|
||||
rect.bottom += 1;
|
||||
FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));
|
||||
|
||||
pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);
|
||||
pt[0].y = rect.bottom / 2;
|
||||
pt[1].x = pt[0].x + 4;
|
||||
pt[1].y = pt[0].y;
|
||||
pt[2].x = pt[1].x - 2;
|
||||
pt[2].y = pt[1].y + 2;
|
||||
|
||||
oldPen = (HPEN) SelectObject(hdc, GetStockPen(WHITE_PEN));
|
||||
oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(WHITE_BRUSH));
|
||||
Polygon(hdc, pt, 3);
|
||||
|
||||
SelectObject(hdc, oldPen);
|
||||
SelectObject(hdc, oldBrush);
|
||||
}
|
||||
else
|
||||
{
|
||||
HBRUSH oldBrush;
|
||||
POINT pt[3];
|
||||
|
||||
FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DFACE));
|
||||
rect.top -= 1;
|
||||
rect.bottom += 1;
|
||||
FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));
|
||||
|
||||
pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);
|
||||
pt[0].y = rect.bottom / 2;
|
||||
pt[1].x = pt[0].x + 4;
|
||||
pt[1].y = pt[0].y;
|
||||
pt[2].x = pt[1].x - 2;
|
||||
pt[2].y = pt[1].y + 2;
|
||||
|
||||
oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(BLACK_BRUSH));
|
||||
Polygon(hdc, pt, 3);
|
||||
|
||||
SelectObject(hdc, oldBrush);
|
||||
}
|
||||
|
||||
|
||||
if(wParam == 0)
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check if mouse is within drop-arrow area, toggle
|
||||
* a flag to say if the mouse is up/down. Then invalidate
|
||||
* the window so it redraws to show the changes. */
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
|
||||
pt.x = (short)LOWORD(lParam);
|
||||
pt.y = (short)HIWORD(lParam);
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
|
||||
InflateRect(&rect,
|
||||
-GetSystemMetrics(SM_CXEDGE),
|
||||
-GetSystemMetrics(SM_CYEDGE));
|
||||
rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
|
||||
|
||||
if(PtInRect(&rect, pt))
|
||||
{
|
||||
/* we *should* call SetCapture, but the ComboBox does it for us */
|
||||
fMouseDown = TRUE;
|
||||
fButtonDown = TRUE;
|
||||
InvalidateRect(hwnd, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* mouse has moved. Check to see if it is in/out of the drop-arrow */
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
|
||||
pt.x = (short)LOWORD(lParam);
|
||||
pt.y = (short)HIWORD(lParam);
|
||||
|
||||
if(fMouseDown && (wParam & MK_LBUTTON))
|
||||
{
|
||||
GetClientRect(hwnd, &rect);
|
||||
|
||||
InflateRect(&rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
|
||||
rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
|
||||
|
||||
if(fButtonDown != PtInRect(&rect, pt))
|
||||
{
|
||||
fButtonDown = PtInRect(&rect, pt);
|
||||
InvalidateRect(hwnd, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
|
||||
if(fMouseDown)
|
||||
{
|
||||
/* No need to call ReleaseCapture, the ComboBox does it for us */
|
||||
fMouseDown = FALSE;
|
||||
fButtonDown = FALSE;
|
||||
InvalidateRect(hwnd, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CallWindowProc(OldComboProc,
|
||||
hwnd,
|
||||
msg,
|
||||
wParam,
|
||||
lParam);
|
||||
}
|
||||
|
||||
VOID MakeFlatCombo(HWND hwndCombo)
|
||||
{
|
||||
LONG OldComboProc;
|
||||
|
||||
/* Remember old window procedure */
|
||||
OldComboProc = GetWindowLongPtr(hwndCombo, GWL_WNDPROC);
|
||||
SetWindowLongPtr(hwndCombo,
|
||||
GWL_USERDATA,
|
||||
OldComboProc);
|
||||
|
||||
/* Perform the subclass */
|
||||
SetWindowLongPtr(hwndCombo,
|
||||
GWL_WNDPROC,
|
||||
(LONG_PTR)FlatComboProc);
|
||||
}
|
629
rosapps/imagesoft/floatwindow.c
Normal file
|
@ -0,0 +1,629 @@
|
|||
#include "precomp.h"
|
||||
|
||||
static const TCHAR szFloatWndClass[] = TEXT("ImageSoftFloatWndClass");
|
||||
|
||||
#define ID_TIMER1 1
|
||||
#define ID_TIMER2 2
|
||||
#define ID_TIMER3 3
|
||||
|
||||
TBBUTTON ToolsButtons[] = {
|
||||
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
||||
{TBICON_RECTSEL, ID_RECTSEL, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* rectangle select */
|
||||
{TBICON_MOVESEL, ID_MOVESEL, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* move selected pixels */
|
||||
{TBICON_LASOO, ID_LASOO, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* lasso select */
|
||||
{TBICON_MOVE, ID_MOVE, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* move selection */
|
||||
{TBICON_ECLIPSESEL, ID_ECLIPSESEL, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* elipse select */
|
||||
{TBICON_ZOOM, ID_ZOOM, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* zoom */
|
||||
{TBICON_MAGICWAND, ID_MAGICWAND, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* magic wand */
|
||||
{TBICON_TEXT, ID_TEXT, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* text */
|
||||
{TBICON_PAINTBRUSH, ID_PAINTBRUSH, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* paintbrush */
|
||||
{TBICON_ERASER, ID_ERASER, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* eraser */
|
||||
{TBICON_PENCIL, ID_PENCIL, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* pencil */
|
||||
{TBICON_COLORPICKER, ID_COLORPICKER, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* color picker */
|
||||
{TBICON_CLONESTAMP, ID_CLONESTAMP, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* clone stamp */
|
||||
{TBICON_RECOLORING, ID_RECOLORING, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* recolor */
|
||||
{TBICON_PAINTBUCKET, ID_PAINTBUCKET, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* paint bucket */
|
||||
{TBICON_LINE, ID_LINE, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* line */
|
||||
{TBICON_RECTANGLE, ID_RECTANGLE, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* rectangle */
|
||||
{TBICON_ROUNDRECT, ID_ROUNDRECT, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* round rectangle */
|
||||
{TBICON_ECLIPSE, ID_ECLIPSE, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* elipse */
|
||||
{TBICON_FREEFORM, ID_FREEFORM, TBSTATE_ENABLED, BTNS_BUTTON | TBSTYLE_GROUP | TBSTYLE_CHECK, {0}, 0, 0}, /* free form */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
||||
};
|
||||
|
||||
TBBUTTON HistoryButtons[] = {
|
||||
{TBICON_BACKSM, ID_BACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* back */
|
||||
{TBICON_UNDOSM, ID_UNDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* undo */
|
||||
{TBICON_REDOSM, ID_REDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* redo */
|
||||
{TBICON_FORWARDSM, ID_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* forward */
|
||||
{TBICON_DELETESM, ID_DELETE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* delete */
|
||||
};
|
||||
|
||||
|
||||
BOOL
|
||||
ShowHideWindow(HWND hwnd)
|
||||
{
|
||||
if (IsWindowVisible(hwnd))
|
||||
return ShowWindow(hwnd, SW_HIDE);
|
||||
else
|
||||
return ShowWindow(hwnd, SW_SHOW);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info)
|
||||
{
|
||||
HWND hTb;
|
||||
HIMAGELIST hImageList;
|
||||
INT NumButtons;
|
||||
|
||||
NumButtons = sizeof(ToolsButtons) / sizeof(ToolsButtons[0]);
|
||||
|
||||
hTb = CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_WRAPABLE | CCS_NODIVIDER,
|
||||
0, 0, 32, 200,
|
||||
Info->fltTools->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hTb != NULL)
|
||||
{
|
||||
SendMessage(hTb,
|
||||
TB_SETEXTENDEDSTYLE,
|
||||
0,
|
||||
TBSTYLE_EX_HIDECLIPPEDBUTTONS);
|
||||
|
||||
SendMessage(hTb,
|
||||
TB_BUTTONSTRUCTSIZE,
|
||||
sizeof(ToolsButtons[0]),
|
||||
0);
|
||||
|
||||
SendMessage(hTb,
|
||||
TB_SETBITMAPSIZE,
|
||||
0,
|
||||
(LPARAM)MAKELONG(16, 16));
|
||||
|
||||
hImageList = InitImageList(NumButtons,
|
||||
IDB_TOOLSRECTSEL);
|
||||
|
||||
ImageList_Destroy((HIMAGELIST)SendMessage(hTb,
|
||||
TB_SETIMAGELIST,
|
||||
0,
|
||||
(LPARAM)hImageList));
|
||||
|
||||
SendMessage(hTb,
|
||||
TB_ADDBUTTONS,
|
||||
NumButtons,
|
||||
(LPARAM)ToolsButtons);
|
||||
|
||||
SendMessage(hTb,
|
||||
TB_AUTOSIZE,
|
||||
0,
|
||||
0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
FloatWindowPaintColorPicker(HWND hColorPicker)
|
||||
{
|
||||
HDC hdc;
|
||||
RECT rect;
|
||||
|
||||
InvalidateRect(hColorPicker,
|
||||
NULL,
|
||||
TRUE);
|
||||
UpdateWindow(hColorPicker);
|
||||
|
||||
hdc = GetDC(hColorPicker);
|
||||
|
||||
GetClientRect(hColorPicker,
|
||||
&rect);
|
||||
|
||||
Ellipse(hdc,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right,
|
||||
rect.bottom);
|
||||
|
||||
ReleaseDC(hColorPicker,
|
||||
hdc);
|
||||
|
||||
}
|
||||
|
||||
VOID
|
||||
FloatWindowPaintHueSlider(HWND hHueSlider)
|
||||
{
|
||||
HDC hdc;
|
||||
RECT rect;
|
||||
|
||||
InvalidateRect(hHueSlider,
|
||||
NULL,
|
||||
TRUE);
|
||||
UpdateWindow(hHueSlider);
|
||||
|
||||
hdc = GetDC(hHueSlider);
|
||||
|
||||
GetClientRect(hHueSlider,
|
||||
&rect);
|
||||
|
||||
Rectangle(hdc,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right,
|
||||
rect.bottom);
|
||||
|
||||
ReleaseDC(hHueSlider,
|
||||
hdc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
FloatToolbarCreateColorsGui(PMAIN_WND_INFO Info)
|
||||
{
|
||||
HWND hColorPicker;
|
||||
HWND hHueSlider;
|
||||
HWND hMouseButton;
|
||||
HWND hMore;
|
||||
RECT rect;
|
||||
HBITMAP hMoreBitmap;
|
||||
|
||||
GetClientRect(Info->fltColors->hSelf,
|
||||
&rect);
|
||||
|
||||
hColorPicker = CreateWindowEx(0,
|
||||
WC_STATIC,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
|
||||
2,
|
||||
2,
|
||||
(int) (rect.right * 0.65),
|
||||
rect.bottom - 2,
|
||||
Info->fltColors->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hColorPicker == NULL)
|
||||
return FALSE;
|
||||
|
||||
hHueSlider = CreateWindowEx(0,
|
||||
WC_STATIC,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
|
||||
145,
|
||||
35,
|
||||
25,
|
||||
135,
|
||||
Info->fltColors->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hHueSlider == NULL)
|
||||
return FALSE;
|
||||
|
||||
hMouseButton = CreateWindowEx(0,
|
||||
WC_COMBOBOX,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
|
||||
118, 5, 75, 25,
|
||||
Info->fltColors->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hMouseButton == NULL)
|
||||
return FALSE;
|
||||
|
||||
MakeFlatCombo(hMouseButton);
|
||||
|
||||
/* temp, just testing */
|
||||
SendMessage(hMouseButton, CB_ADDSTRING, 0, (LPARAM)_T("Primary"));
|
||||
SendMessage(hMouseButton, CB_ADDSTRING, 0, (LPARAM)_T("Secondary"));
|
||||
SendMessage(hMouseButton, CB_SETCURSEL, 0, 0);
|
||||
|
||||
|
||||
hMore = CreateWindowEx(WS_EX_STATICEDGE,
|
||||
WC_BUTTON,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | BS_BITMAP,
|
||||
rect.right - 15,
|
||||
rect.bottom - 15,
|
||||
15, 15,
|
||||
Info->fltColors->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hMore == NULL)
|
||||
return FALSE;
|
||||
|
||||
hMoreBitmap = (HBITMAP)LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDB_COLORSMORE),
|
||||
IMAGE_BITMAP,
|
||||
12,
|
||||
11,
|
||||
LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS);
|
||||
if (hMoreBitmap != NULL)
|
||||
{
|
||||
SendMessage(hMore,
|
||||
BM_SETIMAGE,
|
||||
IMAGE_BITMAP,
|
||||
(LPARAM)hMoreBitmap);
|
||||
}
|
||||
|
||||
|
||||
/* temp functions for playing about with possible layouts */
|
||||
FloatWindowPaintHueSlider(hHueSlider);
|
||||
FloatWindowPaintColorPicker(hColorPicker);
|
||||
|
||||
if (hColorPicker != NULL)
|
||||
{
|
||||
HDC hDc = GetDC(hColorPicker);
|
||||
TextOut(hDc, 8, 75, _T("Possible layout?"), 16);
|
||||
ReleaseDC(hColorPicker, hDc);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info)
|
||||
{
|
||||
HWND hList;
|
||||
HWND hButtons;
|
||||
HIMAGELIST hImageList;
|
||||
INT NumButtons;
|
||||
|
||||
hList = CreateWindowEx(0,
|
||||
WC_LISTBOX,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | LBS_EXTENDEDSEL,
|
||||
0, 0, 143, 100,
|
||||
Info->fltHistory->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hList == NULL)
|
||||
return FALSE;
|
||||
|
||||
NumButtons = sizeof(HistoryButtons) / sizeof(HistoryButtons[0]);
|
||||
hButtons = CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | CCS_BOTTOM | CCS_NODIVIDER,
|
||||
0, 0, 0, 0,
|
||||
Info->fltHistory->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hButtons != NULL)
|
||||
{
|
||||
SendMessage(hButtons,
|
||||
TB_BUTTONSTRUCTSIZE,
|
||||
sizeof(ToolsButtons[0]),
|
||||
0);
|
||||
|
||||
SendMessage(hButtons,
|
||||
TB_SETBITMAPSIZE,
|
||||
0,
|
||||
(LPARAM)MAKELONG(10, 10));
|
||||
|
||||
hImageList = InitImageList(NumButtons,
|
||||
IDB_HISTBACK);
|
||||
|
||||
ImageList_Destroy((HIMAGELIST)SendMessage(hButtons,
|
||||
TB_SETIMAGELIST,
|
||||
0,
|
||||
(LPARAM)hImageList));
|
||||
|
||||
SendMessage(hButtons,
|
||||
TB_SETBUTTONSIZE,
|
||||
0,
|
||||
MAKELONG(18, 16));
|
||||
|
||||
SendMessage(hButtons,
|
||||
TB_ADDBUTTONS,
|
||||
NumButtons,
|
||||
(LPARAM)HistoryButtons);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DoTimer(PFLT_WND FltInfo,
|
||||
UINT idTimer)
|
||||
{
|
||||
switch (idTimer)
|
||||
{
|
||||
/* timer to check if cursor is in toolbar coords */
|
||||
case ID_TIMER1:
|
||||
{
|
||||
POINT pt;
|
||||
|
||||
/* kill timer if toobar is not opaque */
|
||||
if (FltInfo->bOpaque != TRUE)
|
||||
{
|
||||
KillTimer(FltInfo->hSelf,
|
||||
ID_TIMER1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetCursorPos(&pt))
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
if (GetWindowRect(FltInfo->hSelf,
|
||||
&rect))
|
||||
{
|
||||
if (!PtInRect(&rect,
|
||||
pt))
|
||||
{
|
||||
KillTimer(FltInfo->hSelf,
|
||||
ID_TIMER1);
|
||||
KillTimer(FltInfo->hSelf,
|
||||
ID_TIMER2);
|
||||
|
||||
/* timer to fade out toolbar */
|
||||
SetTimer(FltInfo->hSelf,
|
||||
ID_TIMER3,
|
||||
50,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* timer to fade in toolbar */
|
||||
case ID_TIMER2:
|
||||
{
|
||||
SetLayeredWindowAttributes(FltInfo->hSelf,
|
||||
0,
|
||||
(255 * FltInfo->Transparancy) / 100,
|
||||
LWA_ALPHA);
|
||||
|
||||
/* increment transparancy until it is opaque (100) */
|
||||
FltInfo->Transparancy += 5;
|
||||
|
||||
if (FltInfo->Transparancy == 100)
|
||||
{
|
||||
SetWindowLongPtr(FltInfo->hSelf,
|
||||
GWL_EXSTYLE,
|
||||
GetWindowLongPtr(FltInfo->hSelf,
|
||||
GWL_EXSTYLE) & ~WS_EX_LAYERED);
|
||||
|
||||
FltInfo->bOpaque = TRUE;
|
||||
|
||||
KillTimer(FltInfo->hSelf,
|
||||
ID_TIMER2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_TIMER3:
|
||||
{
|
||||
LONG Style;
|
||||
|
||||
Style = GetWindowLongPtr(FltInfo->hSelf,
|
||||
GWL_EXSTYLE);
|
||||
|
||||
if (Style & ~WS_EX_LAYERED)
|
||||
{
|
||||
SetWindowLongPtr(FltInfo->hSelf,
|
||||
GWL_EXSTYLE,
|
||||
Style | WS_EX_LAYERED);
|
||||
}
|
||||
|
||||
FltInfo->Transparancy -= 5;
|
||||
|
||||
if (FltInfo->Transparancy >= 60)
|
||||
{
|
||||
/* set the tranclucency to 60% */
|
||||
SetLayeredWindowAttributes(FltInfo->hSelf,
|
||||
0,
|
||||
(255 * FltInfo->Transparancy) / 100,
|
||||
LWA_ALPHA);
|
||||
|
||||
if (FltInfo->Transparancy == 60)
|
||||
{
|
||||
FltInfo->bOpaque = FALSE;
|
||||
|
||||
KillTimer(FltInfo->hSelf,
|
||||
ID_TIMER3);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
FloatToolbarWndProc(HWND hwnd,
|
||||
UINT Message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
PFLT_WND FltInfo;
|
||||
|
||||
/* Get the window context */
|
||||
FltInfo = (PFLT_WND)GetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA);
|
||||
if (FltInfo == NULL && Message != WM_CREATE)
|
||||
{
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
switch(Message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
FltInfo = (PFLT_WND)(((LPCREATESTRUCT)lParam)->lpCreateParams);
|
||||
|
||||
/*FIXME: read this from registry */
|
||||
// FltInfo->bShow = TRUE;
|
||||
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
(LONG_PTR)FltInfo);
|
||||
|
||||
FltInfo->bOpaque = FALSE;
|
||||
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWL_EXSTYLE,
|
||||
GetWindowLongPtr(hwnd,
|
||||
GWL_EXSTYLE) | WS_EX_LAYERED);
|
||||
|
||||
/* set the tranclucency to 60% */
|
||||
FltInfo->Transparancy = 60;
|
||||
SetLayeredWindowAttributes(hwnd,
|
||||
0,
|
||||
(255 * FltInfo->Transparancy) / 100,
|
||||
LWA_ALPHA);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
{
|
||||
DoTimer(FltInfo,
|
||||
wParam);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCMOUSEMOVE:
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (FltInfo->bOpaque == FALSE)
|
||||
{
|
||||
|
||||
RedrawWindow(hwnd,
|
||||
NULL,
|
||||
NULL,
|
||||
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
|
||||
|
||||
FltInfo->bOpaque = TRUE;
|
||||
//MessageBox(NULL, _T("in"), _T("Hit test"), MB_OK | MB_ICONEXCLAMATION);
|
||||
|
||||
/* timer to check if cursor is in toolbar coords */
|
||||
SetTimer(hwnd,
|
||||
ID_TIMER1,
|
||||
200,
|
||||
NULL);
|
||||
|
||||
/* timer to fade in the toolbars */
|
||||
SetTimer(hwnd,
|
||||
ID_TIMER2,
|
||||
50,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
ShowHideWindow(FltInfo->hSelf);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if (LOWORD(wParam) == IDCANCEL)
|
||||
ShowHideWindow(FltInfo->hSelf);
|
||||
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case ID_NEW:
|
||||
MessageBox(hwnd, _T("Kapow!"), _T("Hit test"), MB_OK | MB_ICONEXCLAMATION);
|
||||
break;
|
||||
|
||||
case ID_CLONESTAMP:
|
||||
case ID_COLORPICKER:
|
||||
case ID_ECLIPSE:
|
||||
case ID_ECLIPSESEL:
|
||||
case ID_ERASER:
|
||||
case ID_FREEFORM:
|
||||
case ID_LASOO:
|
||||
case ID_LINE:
|
||||
case ID_MAGICWAND:
|
||||
case ID_MOVE:
|
||||
case ID_MOVESEL:
|
||||
case ID_PAINTBRUSH:
|
||||
case ID_PAINTBUCKET:
|
||||
case ID_PENCIL:
|
||||
case ID_RECOLORING:
|
||||
case ID_RECTANGLE:
|
||||
case ID_ROUNDRECT:
|
||||
case ID_TEXT:
|
||||
case ID_ZOOM:
|
||||
/*SendMessage(Info->hSelf,
|
||||
LOWORD(wParam),
|
||||
wParam,
|
||||
lParam);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCACTIVATE:
|
||||
/* FIXME: needs fully implementing */
|
||||
return DefWindowProc(hwnd,
|
||||
Message,
|
||||
TRUE,
|
||||
lParam);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
0);
|
||||
break;
|
||||
|
||||
default:
|
||||
HandleDefaultMessage:
|
||||
return DefWindowProc(hwnd,
|
||||
Message,
|
||||
wParam,
|
||||
lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
InitFloatWndClass(VOID)
|
||||
{
|
||||
WNDCLASSEX wc = {0};
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = FloatToolbarWndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursor(NULL,
|
||||
IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszClassName = szFloatWndClass;
|
||||
wc.hIconSm = NULL;
|
||||
|
||||
return RegisterClassEx(&wc) != (ATOM)0;
|
||||
}
|
||||
|
||||
VOID
|
||||
UninitFloatWndImpl(VOID)
|
||||
{
|
||||
UnregisterClass(szFloatWndClass,
|
||||
hInstance);
|
||||
}
|
||||
|
||||
|
178
rosapps/imagesoft/font.c
Normal file
|
@ -0,0 +1,178 @@
|
|||
#include <precomp.h>
|
||||
|
||||
int CALLBACK
|
||||
EnumFontSizes(ENUMLOGFONTEX *lpelfe,
|
||||
NEWTEXTMETRICEX *lpntme,
|
||||
DWORD FontType,
|
||||
LPARAM lParam)
|
||||
{
|
||||
static int ttsizes[] = { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 };
|
||||
TCHAR ach[100];
|
||||
|
||||
BOOL fTrueType = (lpelfe->elfLogFont.lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE;
|
||||
|
||||
HWND hwndCombo = (HWND)lParam;
|
||||
INT i, idx;
|
||||
|
||||
if (fTrueType)
|
||||
{
|
||||
for (i = 0; i < (sizeof(ttsizes) / sizeof(ttsizes[0])); i++)
|
||||
{
|
||||
wsprintf(ach, _T("%d"), ttsizes[i]);
|
||||
|
||||
idx = (INT)SendMessage(hwndCombo,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)ach);
|
||||
|
||||
SendMessage(hwndCombo,
|
||||
CB_SETITEMDATA,
|
||||
idx,
|
||||
ttsizes[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Font-enumeration callback */
|
||||
int CALLBACK
|
||||
EnumFontNames(ENUMLOGFONTEX *lpelfe,
|
||||
NEWTEXTMETRICEX *lpntme,
|
||||
DWORD FontType,
|
||||
LPARAM lParam)
|
||||
{
|
||||
HWND hwndCombo = (HWND)lParam;
|
||||
TCHAR *pszName = lpelfe->elfLogFont.lfFaceName;
|
||||
|
||||
/* make sure font doesn't already exist in our list */
|
||||
if(SendMessage(hwndCombo,
|
||||
CB_FINDSTRING,
|
||||
0,
|
||||
(LPARAM)pszName) == CB_ERR)
|
||||
{
|
||||
INT idx;
|
||||
BOOL fFixed;
|
||||
BOOL fTrueType;
|
||||
|
||||
/* add the font */
|
||||
idx = (INT)SendMessage(hwndCombo,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszName);
|
||||
|
||||
/* record the font's attributes (Fixedwidth and Truetype) */
|
||||
fFixed = (lpelfe->elfLogFont.lfPitchAndFamily & FIXED_PITCH) ? TRUE : FALSE;
|
||||
fTrueType = (lpelfe->elfLogFont.lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE;
|
||||
|
||||
/* store this information in the list-item's userdata area */
|
||||
SendMessage(hwndCombo,
|
||||
CB_SETITEMDATA,
|
||||
idx,
|
||||
MAKEWPARAM(fFixed, fTrueType));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
FillFontSizeComboList(HWND hwndCombo)
|
||||
{
|
||||
LOGFONT lf = { 0 };
|
||||
HDC hdc = GetDC(hwndCombo);
|
||||
|
||||
/* default size */
|
||||
INT cursize = 12;
|
||||
INT i, count, nearest = 0;
|
||||
|
||||
HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
|
||||
|
||||
SendMessage(hwndCombo,
|
||||
WM_SETFONT,
|
||||
(WPARAM)hFont,
|
||||
0);
|
||||
|
||||
lf.lfCharSet = DEFAULT_CHARSET;
|
||||
lf.lfPitchAndFamily = 0;
|
||||
|
||||
/* empty the list */
|
||||
SendMessage(hwndCombo,
|
||||
CB_RESETCONTENT,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* enumerate font sizes */
|
||||
EnumFontFamiliesEx(hdc,
|
||||
&lf,
|
||||
(FONTENUMPROC)EnumFontSizes,
|
||||
(LPARAM)hwndCombo,
|
||||
0);
|
||||
|
||||
/* set selection to first item */
|
||||
count = (INT)SendMessage(hwndCombo,
|
||||
CB_GETCOUNT,
|
||||
0,
|
||||
0);
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
INT n = (INT)SendMessage(hwndCombo,
|
||||
CB_GETITEMDATA,
|
||||
i,
|
||||
0);
|
||||
|
||||
if (n <= cursize)
|
||||
nearest = i;
|
||||
}
|
||||
|
||||
SendMessage(hwndCombo,
|
||||
CB_SETCURSEL,
|
||||
nearest,
|
||||
0);
|
||||
|
||||
ReleaseDC(hwndCombo,
|
||||
hdc);
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the font-list by enumeration all system fonts */
|
||||
VOID
|
||||
FillFontStyleComboList(HWND hwndCombo)
|
||||
{
|
||||
HDC hdc = GetDC(hwndCombo);
|
||||
LOGFONT lf;
|
||||
|
||||
/* FIXME: draw each font in its own style */
|
||||
HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
|
||||
SendMessage(hwndCombo,
|
||||
WM_SETFONT,
|
||||
(WPARAM)hFont,
|
||||
0);
|
||||
|
||||
/* FIXME: set this in relation to the widest string */
|
||||
SendMessage(hwndCombo, CB_SETDROPPEDWIDTH, 150, 0);
|
||||
|
||||
lf.lfCharSet = ANSI_CHARSET; // DEFAULT_CHARSET;
|
||||
lf.lfFaceName[0] = _T('\0'); // all fonts
|
||||
lf.lfPitchAndFamily = 0;
|
||||
|
||||
/* store the list of fonts in the combo */
|
||||
EnumFontFamiliesEx(hdc,
|
||||
&lf,
|
||||
(FONTENUMPROC)EnumFontNames,
|
||||
(LPARAM)hwndCombo, 0);
|
||||
|
||||
ReleaseDC(hwndCombo,
|
||||
hdc);
|
||||
|
||||
/* set default to Arial */
|
||||
SendMessage(hwndCombo,
|
||||
CB_SELECTSTRING,
|
||||
-1,
|
||||
(LPARAM)_T("Arial"));
|
||||
|
||||
|
||||
}
|
49
rosapps/imagesoft/imageprop.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
typedef struct _IMAGEADJUST
|
||||
{
|
||||
PMAIN_WND_INFO Info;
|
||||
HWND hPicPrev;
|
||||
HBITMAP hBitmap;
|
||||
HBITMAP hPreviewBitmap;
|
||||
RECT ImageRect;
|
||||
INT RedVal;
|
||||
INT GreenVal;
|
||||
INT BlueVal;
|
||||
} IMAGEADJUST, *PIMAGEADJUST;
|
||||
|
||||
|
||||
INT_PTR CALLBACK ImagePropDialogProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
INT_PTR CALLBACK BrightnessProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
INT_PTR CALLBACK ContrastProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
VOID AdjustBrightness(HBITMAP hOrigBitmap,
|
||||
HBITMAP hNewBitmap,
|
||||
HWND hwnd,
|
||||
HDC hdcMem,
|
||||
INT RedVal,
|
||||
INT GreenVal,
|
||||
INT BlueVal);
|
||||
|
||||
BOOL DisplayBlackAndWhite(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap);
|
||||
BOOL DisplayInvertedColors(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap);
|
||||
BOOL DisplayBlur(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap);
|
||||
BOOL DisplaySharpness(HWND hwnd,
|
||||
HDC hdcMem,
|
||||
HBITMAP hBitmap);
|
100
rosapps/imagesoft/imagesoft.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
#include <precomp.h>
|
||||
|
||||
HINSTANCE hInstance;
|
||||
HANDLE ProcessHeap;
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hThisInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
LPTSTR lpAppName, lpVersion, lpTitle;
|
||||
HWND hMainWnd;
|
||||
MSG Msg;
|
||||
BOOL bRet;
|
||||
int Ret = 1, len;
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
|
||||
hInstance = hThisInstance;
|
||||
ProcessHeap = GetProcessHeap();
|
||||
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
if (!AllocAndLoadString(&lpAppName, hInstance, IDS_APPNAME) ||
|
||||
!AllocAndLoadString(&lpVersion, hInstance, IDS_VERSION) )
|
||||
{
|
||||
return Ret;
|
||||
}
|
||||
|
||||
len = (int)_tcslen(lpAppName) + (int)_tcslen(lpVersion);
|
||||
lpTitle = HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
(len + 2) * sizeof(TCHAR));
|
||||
if (lpTitle == NULL)
|
||||
{
|
||||
LocalFree((HLOCAL)lpAppName);
|
||||
LocalFree((HLOCAL)lpVersion);
|
||||
return Ret;
|
||||
}
|
||||
|
||||
wsprintf(lpTitle,
|
||||
_T("%s %s"),
|
||||
lpAppName,
|
||||
lpVersion);
|
||||
|
||||
LocalFree((HLOCAL)lpAppName);
|
||||
LocalFree((HLOCAL)lpVersion);
|
||||
|
||||
if (TbdInitImpl())
|
||||
{
|
||||
if (InitMainWindowImpl())
|
||||
{
|
||||
if (InitImageEditWindowImpl())
|
||||
{
|
||||
if (InitFloatWndClass())
|
||||
{
|
||||
hMainWnd = CreateMainWindow(lpTitle,
|
||||
nCmdShow);
|
||||
if (hMainWnd != NULL)
|
||||
{
|
||||
/* pump the message queue */
|
||||
while((bRet = GetMessage(&Msg,
|
||||
NULL,
|
||||
0,
|
||||
0) != 0))
|
||||
{
|
||||
if (bRet != (BOOL)-1)
|
||||
{
|
||||
if (!MainWndTranslateMDISysAccel(hMainWnd,
|
||||
&Msg))
|
||||
{
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ret = 0;
|
||||
}
|
||||
|
||||
UninitImageEditWindowImpl();
|
||||
}
|
||||
|
||||
UninitFloatWndImpl();
|
||||
}
|
||||
|
||||
UninitMainWindowImpl();
|
||||
}
|
||||
|
||||
TbdUninitImpl();
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
lpTitle);
|
||||
|
||||
return Ret;
|
||||
}
|
36
rosapps/imagesoft/imagesoft.rbuild
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0"?>
|
||||
<rbuild xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<module name="imagesoft" type="win32gui" installbase="system32" installname="imagesoft.exe">
|
||||
<include base="imagesoft">.</include>
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="__USE_W32API" />
|
||||
<define name="_WIN32_IE">0x0600</define>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<library>kernel32</library>
|
||||
<library>gdi32</library>
|
||||
<library>user32</library>
|
||||
<library>advapi32</library>
|
||||
<library>version</library>
|
||||
<library>comctl32</library>
|
||||
<library>shell32</library>
|
||||
<library>comdlg32</library>
|
||||
<compilationunit name="unit.c">
|
||||
<file>about.c</file>
|
||||
<file>adjust.c</file>
|
||||
<file>brightness.c</file>
|
||||
<file>contrast.c</file>
|
||||
<file>custcombo.c</file>
|
||||
<file>floatwindow.c</file>
|
||||
<file>font.c</file>
|
||||
<file>imagesoft.c</file>
|
||||
<file>imgedwnd.c</file>
|
||||
<file>mainwnd.c</file>
|
||||
<file>opensave.c</file>
|
||||
<file>tooldock.c</file>
|
||||
<file>misc.c</file>
|
||||
</compilationunit>
|
||||
<file>imagesoft.rc</file>
|
||||
<pch>precomp.h</pch>
|
||||
</module>
|
||||
</rbuild>
|
75
rosapps/imagesoft/imagesoft.rc
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS image editor\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "imagesoft\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "imagesoft.exe\0"
|
||||
//#include <reactos/version.rc>
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
1 24 DISCARDABLE "manifest.xml"
|
||||
|
||||
IDI_IMAGESOFTICON ICON "res/imagesoft.ico"
|
||||
|
||||
/* main toolbar icons */
|
||||
IDB_MAINCOPYICON BITMAP DISCARDABLE "res/icons/std/MainCopyIcon.bmp"
|
||||
IDB_MAINCUTICON BITMAP DISCARDABLE "res/icons/std/MainCutIcon.bmp"
|
||||
IDB_MAINPASTEICON BITMAP DISCARDABLE "res/icons/std/MainPasteIcon.bmp"
|
||||
IDB_MAINREDOICON BITMAP DISCARDABLE "res/icons/std/MainRedoIcon.bmp"
|
||||
IDB_MAINUNDOICON BITMAP DISCARDABLE "res/icons/std/MainUndoIcon.bmp"
|
||||
IDB_MAINNEWICON BITMAP DISCARDABLE "res/icons/std/MainNewIcon.bmp"
|
||||
IDB_MAINOPENICON BITMAP DISCARDABLE "res/icons/std/MainOpenIcon.bmp"
|
||||
IDB_MAINPRINTICON BITMAP DISCARDABLE "res/icons/std/MainPrintIcon.bmp"
|
||||
IDB_MAINPRINTPREICON BITMAP DISCARDABLE "res/icons/std/MainPrintPreIcon.bmp"
|
||||
IDB_MAINSAVEICON BITMAP DISCARDABLE "res/icons/std/MainSaveIcon.bmp"
|
||||
|
||||
/* text toolbar icons */
|
||||
IDB_TEXTBOLD BITMAP DISCARDABLE "res/icons/text/TextBoldIcon.bmp"
|
||||
IDB_TEXTITALIC BITMAP DISCARDABLE "res/icons/text/TextItalicIcon.bmp"
|
||||
IDB_TEXTULINE BITMAP DISCARDABLE "res/icons/text/TextUnderlineIcon.bmp"
|
||||
IDB_TEXTLEFT BITMAP DISCARDABLE "res/icons/text/TextAlignLeftIcon.bmp"
|
||||
IDB_TEXTCENTER BITMAP DISCARDABLE "res/icons/text/TextAlignCenterIcon.bmp"
|
||||
IDB_TEXTRIGHT BITMAP DISCARDABLE "res/icons/text/TextAlignRightIcon.bmp"
|
||||
|
||||
/* tools window icons */
|
||||
IDB_TOOLSCLONESTAMP BITMAP DISCARDABLE "res/icons/tools/ToolsCloneStamp.bmp"
|
||||
IDB_TOOLSCOLORPICKER BITMAP DISCARDABLE "res/icons/tools/ToolsColorPicker.bmp"
|
||||
IDB_TOOLSECLIPSE BITMAP DISCARDABLE "res/icons/tools/ToolsEllipse.bmp"
|
||||
IDB_TOOLSECLIPSESEL BITMAP DISCARDABLE "res/icons/tools/ToolsEllipseSelect.bmp"
|
||||
IDB_TOOLSERASER BITMAP DISCARDABLE "res/icons/tools/ToolsEraser.bmp"
|
||||
IDB_TOOLSFREEFORM BITMAP DISCARDABLE "res/icons/tools/ToolsFreeformShape.bmp"
|
||||
IDB_TOOLSLASOO BITMAP DISCARDABLE "res/icons/tools/ToolsLassoSelect.bmp"
|
||||
IDB_TOOLSLINE BITMAP DISCARDABLE "res/icons/tools/ToolsLine.bmp"
|
||||
IDB_TOOLSMAGICWAND BITMAP DISCARDABLE "res/icons/tools/ToolsMagicWand.bmp"
|
||||
IDB_TOOLSMOVE BITMAP DISCARDABLE "res/icons/tools/ToolsMove.bmp"
|
||||
IDB_TOOLSMOVESEL BITMAP DISCARDABLE "res/icons/tools/ToolsMoveSelection.bmp"
|
||||
IDB_TOOLSPAINTBRUSH BITMAP DISCARDABLE "res/icons/tools/ToolsPaintBrush.bmp"
|
||||
IDB_TOOLSPAINTBUCKET BITMAP DISCARDABLE "res/icons/tools/ToolsPaintBucket.bmp"
|
||||
IDB_TOOLSPENCIL BITMAP DISCARDABLE "res/icons/tools/ToolsPencil.bmp"
|
||||
IDB_TOOLSRECOLORING BITMAP DISCARDABLE "res/icons/tools/ToolsRecoloring.bmp"
|
||||
IDB_TOOLSRECTANGLE BITMAP DISCARDABLE "res/icons/tools/ToolsRectangle.bmp"
|
||||
IDB_TOOLSRECTSEL BITMAP DISCARDABLE "res/icons/tools/ToolsRectangleSelect.bmp"
|
||||
IDB_TOOLSROUNDRECT BITMAP DISCARDABLE "res/icons/tools/ToolsRoundedRectangle.bmp"
|
||||
IDB_TOOLSTEXT BITMAP DISCARDABLE "res/icons/tools/ToolsText.bmp"
|
||||
IDB_TOOLSZOOM BITMAP DISCARDABLE "res/icons/tools/ToolsZoom.bmp"
|
||||
|
||||
/* history window icons */
|
||||
IDB_HISTBACK BITMAP DISCARDABLE "res/icons/hist/HistBack.bmp"
|
||||
IDB_HISTUNDO BITMAP DISCARDABLE "res/icons/hist/HistUndo.bmp"
|
||||
IDB_HISTREDO BITMAP DISCARDABLE "res/icons/hist/HistRedo.bmp"
|
||||
IDB_HISTFORWARD BITMAP DISCARDABLE "res/icons/hist/HistForward.bmp"
|
||||
IDB_HISTDELETE BITMAP DISCARDABLE "res/icons/hist/HistDelete.bmp"
|
||||
|
||||
/* colors window icons */
|
||||
IDB_COLORSMORE BITMAP DISCARDABLE "res/icons/color/ColorMore.bmp"
|
||||
IDB_COLORSLESS BITMAP DISCARDABLE "res/icons/color/ColorLess.bmp"
|
||||
|
||||
/* cursors */
|
||||
IDC_PAINTBRUSHCURSOR CURSOR DISCARDABLE "res/cursors/PaintBrushToolCursor.cur"
|
||||
IDC_PAINTBRUSHCURSORMOUSEDOWN CURSOR DISCARDABLE "res/cursors/PaintBrushToolCursorMouseDown.cur"
|
||||
|
||||
#include "rsrc.rc"
|
||||
|
||||
|
542
rosapps/imagesoft/imgedwnd.c
Normal file
|
@ -0,0 +1,542 @@
|
|||
#include "precomp.h"
|
||||
|
||||
static const TCHAR szImageEditWndClass[] = TEXT("ImageSoftEditWndClass");
|
||||
|
||||
#define IMAGE_FRAME_SIZE 1
|
||||
|
||||
static VOID
|
||||
EditWndUpdateScrollInfo(PEDIT_WND_INFO Info)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
RECT rcClient;
|
||||
|
||||
GetClientRect(Info->hSelf,
|
||||
&rcClient);
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_PAGE | SIF_RANGE;
|
||||
si.nPage = rcClient.right - (2 * IMAGE_FRAME_SIZE);
|
||||
si.nMin = 0;
|
||||
si.nMax = Info->Width;
|
||||
|
||||
SetScrollInfo(Info->hSelf,
|
||||
SB_HORZ,
|
||||
&si,
|
||||
TRUE);
|
||||
|
||||
si.nPage = rcClient.bottom - (2 * IMAGE_FRAME_SIZE);
|
||||
si.nMax = Info->Height;
|
||||
SetScrollInfo(Info->hSelf,
|
||||
SB_VERT,
|
||||
&si,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
LoadBlankCanvas(PEDIT_WND_INFO Info)
|
||||
{
|
||||
/* FIXME: convert this to a DIB Section */
|
||||
/* set bitmap dimensions */
|
||||
Info->Width = Info->OpenInfo->New.Width;
|
||||
Info->Height = Info->OpenInfo->New.Height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
LoadDIBImage(PEDIT_WND_INFO Info)
|
||||
{
|
||||
BITMAPFILEHEADER bmfh;
|
||||
HANDLE hFile;
|
||||
BITMAP bitmap;
|
||||
DWORD BytesRead;
|
||||
BOOL bSuccess, bRet = FALSE;
|
||||
|
||||
hFile = CreateFile(Info->OpenInfo->Open.lpImagePath,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return bRet;
|
||||
|
||||
bSuccess = ReadFile(hFile,
|
||||
&bmfh,
|
||||
sizeof(BITMAPFILEHEADER),
|
||||
&BytesRead,
|
||||
NULL);
|
||||
|
||||
if (bSuccess && (BytesRead == sizeof(BITMAPFILEHEADER))
|
||||
&& (bmfh.bfType == *(WORD *)"BM"))
|
||||
{
|
||||
DWORD InfoSize = bmfh.bfOffBits - sizeof(BITMAPFILEHEADER);
|
||||
|
||||
Info->pbmi = HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
InfoSize);
|
||||
if (Info->pbmi)
|
||||
{
|
||||
bSuccess = ReadFile(hFile,
|
||||
Info->pbmi,
|
||||
InfoSize,
|
||||
&BytesRead,
|
||||
NULL);
|
||||
|
||||
if (bSuccess && (BytesRead == InfoSize))
|
||||
{
|
||||
Info->hBitmap = CreateDIBSection(NULL,
|
||||
Info->pbmi,
|
||||
DIB_RGB_COLORS,
|
||||
(VOID *)&Info->pBits,
|
||||
NULL,
|
||||
0);
|
||||
if (Info->hBitmap != NULL)
|
||||
{
|
||||
ReadFile(hFile,
|
||||
Info->pBits,
|
||||
bmfh.bfSize - bmfh.bfOffBits,
|
||||
&BytesRead,
|
||||
NULL);
|
||||
|
||||
GetObject(Info->hBitmap,
|
||||
sizeof(BITMAP),
|
||||
&bitmap);
|
||||
|
||||
Info->Width = bitmap.bmWidth;
|
||||
Info->Height = bitmap.bmHeight;
|
||||
|
||||
bRet = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!bSuccess)
|
||||
{
|
||||
GetError(0);
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
InitEditWnd(PEDIT_WND_INFO Info)
|
||||
{
|
||||
//BOOL bRet = FALSE;
|
||||
|
||||
Info->Zoom = 100;
|
||||
|
||||
if (Info->OpenInfo != NULL)
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
if (Info->hDCMem)
|
||||
{
|
||||
DeleteObject(Info->hDCMem);
|
||||
Info->hDCMem = NULL;
|
||||
}
|
||||
|
||||
hDC = GetDC(Info->hSelf);
|
||||
Info->hDCMem = CreateCompatibleDC(hDC);
|
||||
ReleaseDC(Info->hSelf, hDC);
|
||||
|
||||
if (Info->OpenInfo->CreateNew)
|
||||
{
|
||||
LoadBlankCanvas(Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadDIBImage(Info);
|
||||
}
|
||||
|
||||
Info->OpenInfo = NULL;
|
||||
}
|
||||
|
||||
EditWndUpdateScrollInfo(Info);
|
||||
|
||||
/* Add image editor to the list */
|
||||
Info->Next = Info->MainWnd->ImageEditors;
|
||||
Info->MainWnd->ImageEditors = Info;
|
||||
|
||||
InvalidateRect(Info->hSelf,
|
||||
NULL,
|
||||
TRUE);
|
||||
|
||||
/* FIXME - if returning FALSE, remove the image editor from the list! */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID
|
||||
DestroyEditWnd(PEDIT_WND_INFO Info)
|
||||
{
|
||||
PEDIT_WND_INFO *PrevEditor;
|
||||
PEDIT_WND_INFO Editor;
|
||||
|
||||
DeleteDC(Info->hDCMem);
|
||||
|
||||
/* FIXME - free resources and run down editor */
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info->pbmi);
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info->pBits);
|
||||
|
||||
/* Remove the image editor from the list */
|
||||
PrevEditor = &Info->MainWnd->ImageEditors;
|
||||
Editor = Info->MainWnd->ImageEditors;
|
||||
do
|
||||
{
|
||||
if (Editor == Info)
|
||||
{
|
||||
*PrevEditor = Info->Next;
|
||||
break;
|
||||
}
|
||||
PrevEditor = &Editor->Next;
|
||||
Editor = Editor->Next;
|
||||
} while (Editor != NULL);
|
||||
}
|
||||
|
||||
static VOID
|
||||
ImageEditWndRepaint(PEDIT_WND_INFO Info,
|
||||
HDC hDC,
|
||||
LPPAINTSTRUCT lpps)
|
||||
{
|
||||
HBITMAP hOldBitmap;
|
||||
|
||||
if (Info->hBitmap)
|
||||
{
|
||||
hOldBitmap = (HBITMAP) SelectObject(Info->hDCMem,
|
||||
Info->hBitmap);
|
||||
|
||||
BitBlt(hDC,
|
||||
lpps->rcPaint.left,
|
||||
lpps->rcPaint.top,
|
||||
lpps->rcPaint.right - lpps->rcPaint.left,
|
||||
lpps->rcPaint.bottom - lpps->rcPaint.top,
|
||||
Info->hDCMem,
|
||||
lpps->rcPaint.left,
|
||||
lpps->rcPaint.top,
|
||||
SRCCOPY);
|
||||
|
||||
Info->hBitmap = SelectObject(Info->hDCMem, hOldBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK
|
||||
ImageEditWndProc(HWND hwnd,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
PEDIT_WND_INFO Info;
|
||||
LRESULT Ret = 0;
|
||||
HDC hDC;
|
||||
static INT xMouse, yMouse;
|
||||
static BOOL bLeftButtonDown, bRightButtonDown;
|
||||
|
||||
/* Get the window context */
|
||||
Info = (PEDIT_WND_INFO)GetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA);
|
||||
if (Info == NULL && uMsg != WM_CREATE)
|
||||
{
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
Info = (PEDIT_WND_INFO)(((LPMDICREATESTRUCT)((LPCREATESTRUCT)lParam)->lpCreateParams)->lParam);
|
||||
Info->hSelf = hwnd;
|
||||
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
(LONG_PTR)Info);
|
||||
|
||||
if (!InitEditWnd(Info))
|
||||
{
|
||||
Ret = (LRESULT)-1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case WM_ERASEBKGND:
|
||||
if (Info->Width != 0 && Info->Height != 0)
|
||||
{
|
||||
Ret = TRUE;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case WM_LBUTTONDOWN:
|
||||
if (! bRightButtonDown)
|
||||
SetCapture(Info->hSelf);
|
||||
|
||||
bLeftButtonDown = TRUE;
|
||||
xMouse = LOWORD(lParam);
|
||||
yMouse = HIWORD(lParam);
|
||||
|
||||
SetCursor(LoadCursor(hInstance,
|
||||
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSORMOUSEDOWN)));
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
if (bLeftButtonDown)
|
||||
SetCapture(NULL);
|
||||
|
||||
bLeftButtonDown = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
if (! bLeftButtonDown)
|
||||
SetCapture(Info->hSelf);
|
||||
|
||||
bRightButtonDown = TRUE;
|
||||
xMouse = LOWORD(lParam);
|
||||
yMouse = HIWORD(lParam);
|
||||
|
||||
SetCursor(LoadCursor(hInstance,
|
||||
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSORMOUSEDOWN)));
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
if (bRightButtonDown)
|
||||
SetCapture(NULL);
|
||||
|
||||
bRightButtonDown = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
HPEN hPen, hPenOld;
|
||||
|
||||
if (!bLeftButtonDown && !bRightButtonDown)
|
||||
break;
|
||||
|
||||
hDC = GetDC(Info->hSelf);
|
||||
|
||||
SelectObject(Info->hDCMem,
|
||||
Info->hBitmap);
|
||||
|
||||
if (bLeftButtonDown)
|
||||
hPen = CreatePen(PS_SOLID,
|
||||
3,
|
||||
RGB(0, 0, 0));
|
||||
else
|
||||
hPen = CreatePen(PS_SOLID,
|
||||
3,
|
||||
RGB(255, 255, 255));
|
||||
|
||||
hPenOld = SelectObject(hDC,
|
||||
hPen);
|
||||
SelectObject(Info->hDCMem,
|
||||
hPen);
|
||||
|
||||
MoveToEx(hDC,
|
||||
xMouse,
|
||||
yMouse,
|
||||
NULL);
|
||||
|
||||
MoveToEx(Info->hDCMem,
|
||||
xMouse,
|
||||
yMouse,
|
||||
NULL);
|
||||
|
||||
xMouse = (short)LOWORD(lParam);
|
||||
yMouse = (short)HIWORD(lParam);
|
||||
|
||||
LineTo(hDC,
|
||||
xMouse,
|
||||
yMouse);
|
||||
|
||||
LineTo(Info->hDCMem,
|
||||
xMouse,
|
||||
yMouse);
|
||||
|
||||
SelectObject(hDC,
|
||||
hPenOld);
|
||||
DeleteObject(SelectObject(Info->hDCMem,
|
||||
hPenOld));
|
||||
|
||||
ReleaseDC(Info->hSelf,
|
||||
hDC);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
if (Info->Width != 0 && Info->Height != 0)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
|
||||
hDC = BeginPaint(hwnd,
|
||||
&ps);
|
||||
if (hDC != NULL)
|
||||
{
|
||||
ImageEditWndRepaint(Info,
|
||||
hDC,
|
||||
&ps);
|
||||
|
||||
EndPaint(hwnd,
|
||||
&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
EditWndUpdateScrollInfo(Info);
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
case WM_MENUSELECT:
|
||||
case WM_ENTERMENULOOP:
|
||||
case WM_EXITMENULOOP:
|
||||
/* forward these messages to the main window procedure */
|
||||
Ret = SendMessage(Info->MainWnd->hSelf,
|
||||
uMsg,
|
||||
wParam,
|
||||
lParam);
|
||||
break;
|
||||
|
||||
case WM_MDIACTIVATE:
|
||||
/* Switch the main window context if neccessary */
|
||||
MainWndSwitchEditorContext(Info->MainWnd,
|
||||
(HWND)wParam,
|
||||
(HWND)lParam);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
DestroyEditWnd(Info);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info);
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
0);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
HandleDefaultMessage:
|
||||
Ret = DefMDIChildProc(hwnd,
|
||||
uMsg,
|
||||
wParam,
|
||||
lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
VOID
|
||||
SetImageEditorEnvironment(PEDIT_WND_INFO Info,
|
||||
BOOL Setup)
|
||||
{
|
||||
if (Setup)
|
||||
{
|
||||
/* FIXME - setup editor environment (e.g. show toolbars, enable menus etc) */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME - cleanup editor environment (e.g. hide toolbars, disable menus etc) */
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
CreateImageEditWindow(PMAIN_WND_INFO MainWnd,
|
||||
POPEN_IMAGE_EDIT_INFO OpenInfo)
|
||||
{
|
||||
PEDIT_WND_INFO Info;
|
||||
HWND hWndEditor;
|
||||
LONG Width, Height;
|
||||
|
||||
Info = HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
sizeof(EDIT_WND_INFO));
|
||||
if (Info != NULL)
|
||||
{
|
||||
ZeroMemory(Info,
|
||||
sizeof(EDIT_WND_INFO));
|
||||
Info->MainWnd = MainWnd;
|
||||
Info->MdiEditorType = metImageEditor;
|
||||
Info->OpenInfo = OpenInfo;
|
||||
|
||||
if (OpenInfo->CreateNew)
|
||||
{
|
||||
Width = OpenInfo->New.Width;
|
||||
Height = OpenInfo->New.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Width = CW_USEDEFAULT;
|
||||
Height = CW_USEDEFAULT;
|
||||
}
|
||||
|
||||
hWndEditor = CreateMDIWindow(szImageEditWndClass,
|
||||
OpenInfo->lpImageName,
|
||||
WS_HSCROLL | WS_VSCROLL | WS_MAXIMIZE,
|
||||
200,
|
||||
200,
|
||||
Width,
|
||||
Height,
|
||||
MainWnd->hMdiClient,
|
||||
hInstance,
|
||||
(LPARAM)Info);
|
||||
|
||||
if (hWndEditor != NULL)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitImageEditWindowImpl(VOID)
|
||||
{
|
||||
WNDCLASSEX wc = {0};
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = ImageEditWndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance,
|
||||
MAKEINTRESOURCE(IDI_IMAGESOFTICON));
|
||||
wc.hCursor = LoadCursor(hInstance,
|
||||
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSOR));
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszClassName = szImageEditWndClass;
|
||||
wc.hIconSm = (HICON)LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDI_IMAGESOFTICON),
|
||||
IMAGE_ICON,
|
||||
16,
|
||||
16,
|
||||
LR_SHARED);
|
||||
|
||||
return RegisterClassEx(&wc) != (ATOM)0;
|
||||
}
|
||||
|
||||
VOID
|
||||
UninitImageEditWindowImpl(VOID)
|
||||
{
|
||||
UnregisterClass(szImageEditWndClass,
|
||||
hInstance);
|
||||
}
|
94
rosapps/imagesoft/imgedwnd.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
#define MONOCHROMEBITS 1
|
||||
#define GREYSCALEBITS 8
|
||||
#define PALLETEBITS 8
|
||||
#define TRUECOLORBITS 24
|
||||
|
||||
#define PIXELS 0
|
||||
#define CENTIMETERS 1
|
||||
#define INCHES 2
|
||||
|
||||
|
||||
/* generic definitions and forward declarations */
|
||||
struct _MAIN_WND_INFO;
|
||||
struct _EDIT_WND_INFO;
|
||||
|
||||
|
||||
typedef enum _MDI_EDITOR_TYPE {
|
||||
metUnknown = 0,
|
||||
metImageEditor,
|
||||
} MDI_EDITOR_TYPE, *PMDI_EDITOR_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
tSelect = 0,
|
||||
tMove,
|
||||
tLasso,
|
||||
tZoom,
|
||||
tMagicWand,
|
||||
tBrush,
|
||||
tEraser,
|
||||
tPencil,
|
||||
tColorPick,
|
||||
tStamp,
|
||||
tFill,
|
||||
tLine,
|
||||
tPolyline,
|
||||
tRectangle,
|
||||
tRoundRectangle,
|
||||
tPolygon,
|
||||
tElipse,
|
||||
} TOOL;
|
||||
|
||||
typedef struct _OPEN_IMAGE_EDIT_INFO
|
||||
{
|
||||
BOOL CreateNew;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
LONG Width;
|
||||
LONG Height;
|
||||
} New;
|
||||
struct
|
||||
{
|
||||
LPTSTR lpImagePath;
|
||||
} Open;
|
||||
};
|
||||
LPTSTR lpImageName;
|
||||
USHORT Type;
|
||||
LONG Resolution;
|
||||
} OPEN_IMAGE_EDIT_INFO, *POPEN_IMAGE_EDIT_INFO;
|
||||
|
||||
typedef struct _EDIT_WND_INFO
|
||||
{
|
||||
MDI_EDITOR_TYPE MdiEditorType; /* Must be first member! */
|
||||
|
||||
HWND hSelf;
|
||||
HBITMAP hBitmap;
|
||||
HDC hDCMem;
|
||||
PBITMAPINFO pbmi;
|
||||
PBYTE pBits;
|
||||
struct _MAIN_WND_INFO *MainWnd;
|
||||
struct _EDIT_WND_INFO *Next;
|
||||
POINT ScrollPos;
|
||||
USHORT Zoom;
|
||||
DWORD Tool;
|
||||
|
||||
POPEN_IMAGE_EDIT_INFO OpenInfo; /* Only valid during initialization */
|
||||
|
||||
/* Canvas properties */
|
||||
USHORT Type;
|
||||
LONG Resolution;
|
||||
/* size of drawing area */
|
||||
LONG Width;
|
||||
LONG Height;
|
||||
|
||||
} EDIT_WND_INFO, *PEDIT_WND_INFO;
|
||||
|
||||
|
||||
BOOL CreateImageEditWindow(struct _MAIN_WND_INFO *MainWnd,
|
||||
POPEN_IMAGE_EDIT_INFO OpenInfo);
|
||||
VOID SetImageEditorEnvironment(PEDIT_WND_INFO Info,
|
||||
BOOL Setup);
|
||||
BOOL InitImageEditWindowImpl(VOID);
|
||||
VOID UninitImageEditWindowImpl(VOID);
|
234
rosapps/imagesoft/lang/en-GB.rc
Normal file
|
@ -0,0 +1,234 @@
|
|||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_VERSION "v0.1"
|
||||
END
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New...", ID_NEW
|
||||
MENUITEM "&Open...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Close\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "C&lose all", ID_CLOSEALL,GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Save", ID_SAVE, GRAYED
|
||||
MENUITEM "Save &As...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Print Pre&view", ID_PRINTPRE,GRAYED
|
||||
MENUITEM "&Print...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Pr&operties...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo", ID_UNDO, GRAYED
|
||||
MENUITEM "&Redo", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t", ID_CUT, GRAYED
|
||||
MENUITEM "&Copy", ID_COPY, GRAYED
|
||||
MENUITEM "&Paste", ID_PASTE, GRAYED
|
||||
MENUITEM "Paste as new &image", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select &All", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Tools", ID_TOOLS
|
||||
MENUITEM "&Colours", ID_COLOR
|
||||
MENUITEM "&History", ID_HISTORY
|
||||
MENUITEM "&Status Bar", ID_STATUSBAR
|
||||
END
|
||||
POPUP "&Adjust"
|
||||
BEGIN
|
||||
MENUITEM "Brightness...", ID_BRIGHTNESS
|
||||
MENUITEM "Contrast...", ID_CONTRAST
|
||||
MENUITEM "Hue/Saturation...", -1, GRAYED
|
||||
POPUP "Colour"
|
||||
BEGIN
|
||||
MENUITEM "Black and White" ID_BLACKANDWHITE
|
||||
MENUITEM "Invert Colours" ID_INVERTCOLORS
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Blur", ID_BLUR
|
||||
MENUITEM "Sharpen", ID_SHARPEN
|
||||
MENUITEM "Smooth Edges", -1, GRAYED
|
||||
MENUITEM "Add Shadow", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Image Size...", -1, GRAYED
|
||||
MENUITEM "Flip", -1, GRAYED
|
||||
MENUITEM "Mirror", -1, GRAYED
|
||||
MENUITEM "Rotate", -1, GRAYED
|
||||
|
||||
END
|
||||
POPUP "&Colours"
|
||||
BEGIN
|
||||
MENUITEM "&Edit Colours...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "&Window"
|
||||
BEGIN
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "Tile &Horizontally", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "Tile &Vertically", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Nex&t\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU
|
||||
BEGIN
|
||||
POPUP "popup"
|
||||
BEGIN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
IDD_BRIGHTNESS DIALOGEX 6, 5, 193, 120
|
||||
CAPTION "Brightness"
|
||||
FONT 8,"MS Sans Serif", 0, 0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "", IDC_PICPREVIEW, 0, 1, 132, 96, SS_OWNERDRAW | SS_SUNKEN
|
||||
LTEXT "Colour form:", IDC_STATIC, 135, 5, 36, 9
|
||||
GROUPBOX "", IDC_BRI_GROUP, 138 ,30, 50, 48
|
||||
CONTROL "Full (RGB)", IDC_BRI_FULL, "Button", BS_AUTORADIOBUTTON, 138, 18, 46, 9
|
||||
CONTROL "Red", IDC_BRI_RED, "Button", BS_AUTORADIOBUTTON, 142, 38, 42, 9
|
||||
CONTROL "Green", IDC_BRI_GREEN, "Button", BS_AUTORADIOBUTTON, 142, 51, 42, 9
|
||||
CONTROL "Blue", IDC_BRI_BLUE, "Button", BS_AUTORADIOBUTTON, 142, 64, 42, 9
|
||||
EDITTEXT IDC_BRI_EDIT, 98, 103, 28, 13
|
||||
CONTROL "", IDC_BRI_TRACKBAR, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 2, 105, 90, 11
|
||||
PUSHBUTTON "OK", IDOK, 142, 88, 48, 13
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 142, 105, 48, 13
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22,16,210,182
|
||||
CAPTION "About ImageSoft"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
//EXSTYLE WS_EX_LAYERED
|
||||
BEGIN
|
||||
LTEXT "ImageSoft v0.1\nCopyright (C) 2006\nThomas Weidenmueller (w3seek@reactos.org)\nGed Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 150, 36
|
||||
PUSHBUTTON "Close", IDOK, 75, 162, 44, 15
|
||||
ICON IDI_IMAGESOFTICON, IDC_STATIC, 10, 10, 7, 30
|
||||
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE
|
||||
END
|
||||
|
||||
|
||||
IDD_IMAGE_PROP DIALOGEX 6, 5, 156, 163
|
||||
CAPTION "Image Properties"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "Name:", IDC_STATIC, 12, 5, 38, 9
|
||||
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||
GROUPBOX "Canvas properties", IDC_STATIC, 4, 22, 148, 98
|
||||
LTEXT "Image type:", IDC_STATIC, 12, 36, 42, 9
|
||||
CONTROL "", IDC_IMAGETYPE, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
|
||||
LTEXT "Width:", IDC_STATIC, 12, 51, 42, 9
|
||||
EDITTEXT IDC_WIDTH_EDIT, 58, 49, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_WIDTH_STAT, 94, 51, 40, 9
|
||||
LTEXT "Height:", IDC_STATIC, 12, 68, 42, 9
|
||||
EDITTEXT IDC_HEIGHT_EDIT, 58, 66, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_HEIGHT_STAT, 94, 68, 40, 9
|
||||
LTEXT "Resolution:", IDC_STATIC, 12, 84, 42, 9
|
||||
EDITTEXT IDC_RES_EDIT, 58, 83, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_RES_STAT, 94, 84, 40, 9
|
||||
LTEXT "Unit:", IDC_STATIC, 12, 99, 42, 9
|
||||
CONTROL "", IDC_UNIT, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
|
||||
LTEXT "Image size:", IDC_STATIC, 12, 125, 42, 9
|
||||
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
|
||||
PUSHBUTTON "OK", IDOK, 50, 144, 48, 13
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 102, 144, 48, 13
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
|
||||
IDS_READY " Ready."
|
||||
IDS_TOOLBAR_STANDARD "Standard"
|
||||
IDS_TOOLBAR_TEST "Test"
|
||||
IDS_IMAGE_NAME "Image %1!u!"
|
||||
IDS_FLT_TOOLS "Tools"
|
||||
IDS_FLT_COLORS "Colours"
|
||||
IDS_FLT_HISTORY "History"
|
||||
END
|
||||
|
||||
/* imageprop.c */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_IMAGE_MONOCHROME "Monochrome (1 bit)"
|
||||
IDS_IMAGE_GREYSCALE "Greyscale (8 bit)"
|
||||
IDS_IMAGE_PALETTE "Palette or 256 colour (8 bit)"
|
||||
IDS_IMAGE_TRUECOLOR "True colour (24 bit)"
|
||||
|
||||
IDS_UNIT_PIXELS "Pixels"
|
||||
IDS_UNIT_CM "Cm"
|
||||
IDS_UNIT_INCHES "Inches"
|
||||
IDS_UNIT_DOTSCM "Dots / Cm"
|
||||
IDS_UNIT_DPI "DPI"
|
||||
IDS_UNIT_KB "%d KB"
|
||||
IDS_UNIT_MB "%d MB"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_TOOLTIP_NEW "New"
|
||||
IDS_TOOLTIP_OPEN "Open"
|
||||
IDS_TOOLTIP_SAVE "Save"
|
||||
IDS_TOOLTIP_PRINTPRE "Print preview"
|
||||
IDS_TOOLTIP_PRINT "Print"
|
||||
IDS_TOOLTIP_CUT "Cut"
|
||||
IDS_TOOLTIP_COPY "Copy"
|
||||
IDS_TOOLTIP_PASTE "Paste"
|
||||
IDS_TOOLTIP_UNDO "Undo"
|
||||
IDS_TOOLTIP_REDO "Redo"
|
||||
END
|
||||
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_BLANK " "
|
||||
IDS_HINT_NEW " Creates a new document."
|
||||
IDS_HINT_OPEN " Opens an existing document."
|
||||
IDS_HINT_CLOSE " Closes this window."
|
||||
IDS_HINT_CLOSEALL " Closes all windows."
|
||||
IDS_HINT_SAVE " Saves the active document."
|
||||
IDS_HINT_SAVEAS " Saves the active document with a new name."
|
||||
IDS_HINT_PRINTPRE " Previews the printed document."
|
||||
IDS_HINT_PRINT " Prints the active document."
|
||||
IDS_HINT_PROP " Shows the properties of the active image."
|
||||
IDS_HINT_EXIT " Exits this application."
|
||||
|
||||
IDS_HINT_TOOLS " Shows or hides the tools floating window."
|
||||
IDS_HINT_COLORS " Shows or hides the colours floating window."
|
||||
IDS_HINT_HISTORY " Shows or hides the history floating window."
|
||||
IDS_HINT_STATUS " Shows or hides the status bar."
|
||||
|
||||
IDS_HINT_CASCADE " Arrange windows so they overlap."
|
||||
IDS_HINT_TILE_HORZ " Arrange windows as non-overlapping tiles."
|
||||
IDS_HINT_TILE_VERT " Arrange windows as non-overlapping tiles."
|
||||
IDS_HINT_ARRANGE " Arrange icons at the bottom of the window."
|
||||
IDS_HINT_NEXT " Activates the next window."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " Restores this window to normal size."
|
||||
IDS_HINT_SYS_MOVE " Moves this window."
|
||||
IDS_HINT_SYS_SIZE " Resizes this window."
|
||||
IDS_HINT_SYS_MINIMIZE " Collapses this window to an icon."
|
||||
IDS_HINT_SYS_MAXIMIZE " Expands this window to fill this screen."
|
||||
END
|
234
rosapps/imagesoft/lang/en-US.rc
Normal file
|
@ -0,0 +1,234 @@
|
|||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_VERSION "v0.1"
|
||||
END
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New...", ID_NEW
|
||||
MENUITEM "&Open...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Close\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "C&lose all", ID_CLOSEALL,GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Save", ID_SAVE, GRAYED
|
||||
MENUITEM "Save &As...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Print Pre&view", ID_PRINTPRE,GRAYED
|
||||
MENUITEM "&Print...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Pr&operties...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo", ID_UNDO, GRAYED
|
||||
MENUITEM "&Redo", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t", ID_CUT, GRAYED
|
||||
MENUITEM "&Copy", ID_COPY, GRAYED
|
||||
MENUITEM "&Paste", ID_PASTE, GRAYED
|
||||
MENUITEM "Paste as new &image", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select &All", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Tools", ID_TOOLS
|
||||
MENUITEM "&Colors", ID_COLOR
|
||||
MENUITEM "&History", ID_HISTORY
|
||||
MENUITEM "&Status Bar", ID_STATUSBAR
|
||||
END
|
||||
POPUP "&Adjust"
|
||||
BEGIN
|
||||
MENUITEM "Brightness...", ID_BRIGHTNESS
|
||||
MENUITEM "Contrast...", ID_CONTRAST
|
||||
MENUITEM "Hue/Saturation...", -1, GRAYED
|
||||
POPUP "Color"
|
||||
BEGIN
|
||||
MENUITEM "Black and White" ID_BLACKANDWHITE
|
||||
MENUITEM "Invert Colors" ID_INVERTCOLORS
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Blur", ID_BLUR
|
||||
MENUITEM "Sharpen", ID_SHARPEN
|
||||
MENUITEM "Smooth Edges", -1, GRAYED
|
||||
MENUITEM "Add Shadow", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Image Size...", -1, GRAYED
|
||||
MENUITEM "Flip", -1, GRAYED
|
||||
MENUITEM "Mirror", -1, GRAYED
|
||||
MENUITEM "Rotate", -1, GRAYED
|
||||
|
||||
END
|
||||
POPUP "&Colors"
|
||||
BEGIN
|
||||
MENUITEM "&Edit Colors...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "&Window"
|
||||
BEGIN
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "Tile &Horizontally", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "Tile &Vertically", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Nex&t\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU
|
||||
BEGIN
|
||||
POPUP "popup"
|
||||
BEGIN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
IDD_BRIGHTNESS DIALOGEX 6, 5, 193, 120
|
||||
CAPTION "Brightness"
|
||||
FONT 8,"MS Sans Serif", 0, 0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "", IDC_PICPREVIEW, 0, 1, 132, 96, SS_OWNERDRAW | SS_SUNKEN
|
||||
LTEXT "Color form:", IDC_STATIC, 135, 5, 36, 9
|
||||
GROUPBOX "", IDC_BRI_GROUP, 138 ,30, 50, 48
|
||||
CONTROL "Full (RGB)", IDC_BRI_FULL, "Button", BS_AUTORADIOBUTTON, 138, 18, 46, 9
|
||||
CONTROL "Red", IDC_BRI_RED, "Button", BS_AUTORADIOBUTTON, 142, 38, 42, 9
|
||||
CONTROL "Green", IDC_BRI_GREEN, "Button", BS_AUTORADIOBUTTON, 142, 51, 42, 9
|
||||
CONTROL "Blue", IDC_BRI_BLUE, "Button", BS_AUTORADIOBUTTON, 142, 64, 42, 9
|
||||
EDITTEXT IDC_BRI_EDIT, 98, 103, 28, 13
|
||||
CONTROL "", IDC_BRI_TRACKBAR, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 2, 105, 90, 11
|
||||
PUSHBUTTON "OK", IDOK, 142, 88, 48, 13
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 142, 105, 48, 13
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22,16,210,182
|
||||
CAPTION "About ImageSoft"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
//EXSTYLE WS_EX_LAYERED
|
||||
BEGIN
|
||||
LTEXT "ImageSoft v0.1\nCopyright (C) 2006\nThomas Weidenmueller (w3seek@reactos.org)\nGed Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 150, 36
|
||||
PUSHBUTTON "Close", IDOK, 75, 162, 44, 15
|
||||
ICON IDI_IMAGESOFTICON, IDC_STATIC, 10, 10, 7, 30
|
||||
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE
|
||||
END
|
||||
|
||||
|
||||
IDD_IMAGE_PROP DIALOGEX 6, 5, 156, 163
|
||||
CAPTION "Image Properties"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "Name:", IDC_STATIC, 12, 5, 38, 9
|
||||
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||
GROUPBOX "Canvas properties", IDC_STATIC, 4, 22, 148, 98
|
||||
LTEXT "Image type:", IDC_STATIC, 12, 36, 42, 9
|
||||
CONTROL "", IDC_IMAGETYPE, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
|
||||
LTEXT "Width:", IDC_STATIC, 12, 51, 42, 9
|
||||
EDITTEXT IDC_WIDTH_EDIT, 58, 49, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_WIDTH_STAT, 94, 51, 40, 9
|
||||
LTEXT "Height:", IDC_STATIC, 12, 68, 42, 9
|
||||
EDITTEXT IDC_HEIGHT_EDIT, 58, 66, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_HEIGHT_STAT, 94, 68, 40, 9
|
||||
LTEXT "Resolution:", IDC_STATIC, 12, 84, 42, 9
|
||||
EDITTEXT IDC_RES_EDIT, 58, 83, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_RES_STAT, 94, 84, 40, 9
|
||||
LTEXT "Unit:", IDC_STATIC, 12, 99, 42, 9
|
||||
CONTROL "", IDC_UNIT, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
|
||||
LTEXT "Image size:", IDC_STATIC, 12, 125, 42, 9
|
||||
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
|
||||
PUSHBUTTON "OK", IDOK, 50, 144, 48, 13
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 102, 144, 48, 13
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
|
||||
IDS_READY " Ready."
|
||||
IDS_TOOLBAR_STANDARD "Standard"
|
||||
IDS_TOOLBAR_TEST "Test"
|
||||
IDS_IMAGE_NAME "Image %1!u!"
|
||||
IDS_FLT_TOOLS "Tools"
|
||||
IDS_FLT_COLORS "Colors"
|
||||
IDS_FLT_HISTORY "History"
|
||||
END
|
||||
|
||||
/* imageprop.c */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_IMAGE_MONOCHROME "Monochrome (1 bit)"
|
||||
IDS_IMAGE_GREYSCALE "Grayscale (8 bit)"
|
||||
IDS_IMAGE_PALETTE "Palette or 256 color (8 bit)"
|
||||
IDS_IMAGE_TRUECOLOR "True color (24 bit)"
|
||||
|
||||
IDS_UNIT_PIXELS "Pixels"
|
||||
IDS_UNIT_CM "Cm"
|
||||
IDS_UNIT_INCHES "Inches"
|
||||
IDS_UNIT_DOTSCM "Dots / Cm"
|
||||
IDS_UNIT_DPI "DPI"
|
||||
IDS_UNIT_KB "%d KB"
|
||||
IDS_UNIT_MB "%d MB"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_TOOLTIP_NEW "New"
|
||||
IDS_TOOLTIP_OPEN "Open"
|
||||
IDS_TOOLTIP_SAVE "Save"
|
||||
IDS_TOOLTIP_PRINTPRE "Print preview"
|
||||
IDS_TOOLTIP_PRINT "Print"
|
||||
IDS_TOOLTIP_CUT "Cut"
|
||||
IDS_TOOLTIP_COPY "Copy"
|
||||
IDS_TOOLTIP_PASTE "Paste"
|
||||
IDS_TOOLTIP_UNDO "Undo"
|
||||
IDS_TOOLTIP_REDO "Redo"
|
||||
END
|
||||
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_BLANK " "
|
||||
IDS_HINT_NEW " Creates a new document."
|
||||
IDS_HINT_OPEN " Opens an existing document."
|
||||
IDS_HINT_CLOSE " Closes this window."
|
||||
IDS_HINT_CLOSEALL " Closes all windows."
|
||||
IDS_HINT_SAVE " Saves the active document."
|
||||
IDS_HINT_SAVEAS " Saves the active document with a new name."
|
||||
IDS_HINT_PRINTPRE " Previews the printed document."
|
||||
IDS_HINT_PRINT " Prints the active document."
|
||||
IDS_HINT_PROP " Shows the properties of the active image."
|
||||
IDS_HINT_EXIT " Exits this application."
|
||||
|
||||
IDS_HINT_TOOLS " Shows or hides the tools floating window."
|
||||
IDS_HINT_COLORS " Shows or hides the colors floating window."
|
||||
IDS_HINT_HISTORY " Shows or hides the history floating window."
|
||||
IDS_HINT_STATUS " Shows or hides the status bar."
|
||||
|
||||
IDS_HINT_CASCADE " Arrange windows so they overlap."
|
||||
IDS_HINT_TILE_HORZ " Arrange windows as non-overlapping tiles."
|
||||
IDS_HINT_TILE_VERT " Arrange windows as non-overlapping tiles."
|
||||
IDS_HINT_ARRANGE " Arrange icons at the bottom of the window."
|
||||
IDS_HINT_NEXT " Activates the next window."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " Restores this window to normal size."
|
||||
IDS_HINT_SYS_MOVE " Moves this window."
|
||||
IDS_HINT_SYS_SIZE " Resizes this window."
|
||||
IDS_HINT_SYS_MINIMIZE " Collapses this window to an icon."
|
||||
IDS_HINT_SYS_MAXIMIZE " Expands this window to fill this screen."
|
||||
END
|
234
rosapps/imagesoft/lang/id-ID.rc
Normal file
|
@ -0,0 +1,234 @@
|
|||
LANGUAGE LANG_INDONESIAN, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_VERSION "v0.1"
|
||||
END
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Baru...", ID_NEW
|
||||
MENUITEM "B&uka...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Tutup\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "Tutup s&emua", ID_CLOSEALL,GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Simpan", ID_SAVE, GRAYED
|
||||
MENUITEM "Simpan Seb&agai...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Tin&jau Cetakan", ID_PRINTPRE,GRAYED
|
||||
MENUITEM "&Cetak...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Pr&operti...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Keluar\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo", ID_UNDO, GRAYED
|
||||
MENUITEM "&Redo", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t", ID_CUT, GRAYED
|
||||
MENUITEM "&Copy", ID_COPY, GRAYED
|
||||
MENUITEM "&Paste", ID_PASTE, GRAYED
|
||||
MENUITEM "Paste sebagai gambar &baru", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Pilih &Semua", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "&Lihat"
|
||||
BEGIN
|
||||
MENUITEM "&Piranti", ID_TOOLS
|
||||
MENUITEM "&Warna", ID_COLOR
|
||||
MENUITEM "&Histori", ID_HISTORY
|
||||
MENUITEM "Bar &Status", ID_STATUSBAR
|
||||
END
|
||||
POPUP "Sesu&aikan"
|
||||
BEGIN
|
||||
MENUITEM "Kecerahan...", ID_BRIGHTNESS
|
||||
MENUITEM "Kontras...", ID_CONTRAST
|
||||
MENUITEM "Hue/Saturasi...", -1, GRAYED
|
||||
POPUP "Warna"
|
||||
BEGIN
|
||||
MENUITEM "Hitam dan Putih" ID_BLACKANDWHITE
|
||||
MENUITEM "Balikkan Warna" ID_INVERTCOLORS
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Blur", ID_BLUR
|
||||
MENUITEM "Sharpen", ID_SHARPEN
|
||||
MENUITEM "Lembutkan Sisi", -1, GRAYED
|
||||
MENUITEM "Tambah Bayangan", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Ukuran Gambar...", -1, GRAYED
|
||||
MENUITEM "Flip", -1, GRAYED
|
||||
MENUITEM "Cermin", -1, GRAYED
|
||||
MENUITEM "Rotasi", -1, GRAYED
|
||||
|
||||
END
|
||||
POPUP "&Warna"
|
||||
BEGIN
|
||||
MENUITEM "&Edit Warna...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "&Jendela"
|
||||
BEGIN
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "Tile &Horisontal", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "Tile &Vertikal", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "&Atur Ikon", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Beriku&t\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "&Bantuan"
|
||||
BEGIN
|
||||
MENUITEM "&Tentang...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU
|
||||
BEGIN
|
||||
POPUP "popup"
|
||||
BEGIN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
IDD_BRIGHTNESS DIALOGEX 6, 5, 193, 120
|
||||
CAPTION "Kecerahan"
|
||||
FONT 8,"MS Sans Serif", 0, 0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "", IDC_PICPREVIEW, 0, 1, 132, 96, SS_OWNERDRAW | SS_SUNKEN
|
||||
LTEXT "Form warna:", IDC_STATIC, 135, 5, 36, 9
|
||||
GROUPBOX "", IDC_BRI_GROUP, 138 ,30, 50, 48
|
||||
CONTROL "Penuh (RGB)", IDC_BRI_FULL, "Button", BS_AUTORADIOBUTTON, 138, 18, 46, 9
|
||||
CONTROL "Merah", IDC_BRI_RED, "Button", BS_AUTORADIOBUTTON, 142, 38, 42, 9
|
||||
CONTROL "Hijau", IDC_BRI_GREEN, "Button", BS_AUTORADIOBUTTON, 142, 51, 42, 9
|
||||
CONTROL "Biru", IDC_BRI_BLUE, "Button", BS_AUTORADIOBUTTON, 142, 64, 42, 9
|
||||
EDITTEXT IDC_BRI_EDIT, 98, 103, 28, 13
|
||||
CONTROL "", IDC_BRI_TRACKBAR, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 2, 105, 90, 11
|
||||
PUSHBUTTON "OK", IDOK, 142, 88, 48, 13
|
||||
PUSHBUTTON "Batal", IDCANCEL, 142, 105, 48, 13
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22,16,210,182
|
||||
CAPTION "Tentang ImageSoft"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
//EXSTYLE WS_EX_LAYERED
|
||||
BEGIN
|
||||
LTEXT "ImageSoft v0.1\nHak Cipta (C) 2006\nThomas Weidenmueller (w3seek@reactos.org)\nGed Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 150, 36
|
||||
PUSHBUTTON "Tutup", IDOK, 75, 162, 44, 15
|
||||
ICON IDI_IMAGESOFTICON, IDC_STATIC, 10, 10, 7, 30
|
||||
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE
|
||||
END
|
||||
|
||||
|
||||
IDD_IMAGE_PROP DIALOGEX 6, 5, 156, 163
|
||||
CAPTION "Properti Gambar"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "Nama:", IDC_STATIC, 12, 5, 38, 9
|
||||
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||
GROUPBOX "Properti Kanvas", IDC_STATIC, 4, 22, 148, 98
|
||||
LTEXT "Tipe gambar:", IDC_STATIC, 12, 36, 42, 9
|
||||
CONTROL "", IDC_IMAGETYPE, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
|
||||
LTEXT "Panjang:", IDC_STATIC, 12, 51, 42, 9
|
||||
EDITTEXT IDC_WIDTH_EDIT, 58, 49, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_WIDTH_STAT, 94, 51, 40, 9
|
||||
LTEXT "Tinggi:", IDC_STATIC, 12, 68, 42, 9
|
||||
EDITTEXT IDC_HEIGHT_EDIT, 58, 66, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_HEIGHT_STAT, 94, 68, 40, 9
|
||||
LTEXT "Resolusi:", IDC_STATIC, 12, 84, 42, 9
|
||||
EDITTEXT IDC_RES_EDIT, 58, 83, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_RES_STAT, 94, 84, 40, 9
|
||||
LTEXT "Unit:", IDC_STATIC, 12, 99, 42, 9
|
||||
CONTROL "", IDC_UNIT, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
|
||||
LTEXT "Besar gambar:", IDC_STATIC, 12, 125, 42, 9
|
||||
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
|
||||
PUSHBUTTON "OK", IDOK, 50, 144, 48, 13
|
||||
PUSHBUTTON "Batal", IDCANCEL, 102, 144, 48, 13
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LICENSE "Program ini adalah software bebas; anda dapat mendistribusikan dan/atau mengubahnya di bawah term GNU General Public License seperti dipublikasikan oleh Free Software Foundation; baik Lisensi versi 2, atau (menurut opini anda) setiap versi berikutnya.\r\n\r\nProgram ini didistribusikan dengan harapan ia akan berguna, tetapi TANPA JAMINAN APAPUN; bahkan tanpa jaminan berarti dari MERCANTABILITAS atau KECUKUPAN UNTUK KEPERLUAN TERTENTU. Lihat GNU General Public License untuk lebih jelasnya.\r\n\r\nAnda seharusnya menerima duplikat GNU General Public License bersamaan dengan program ini; jika tidak, tulis ke Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
|
||||
IDS_READY " Siap."
|
||||
IDS_TOOLBAR_STANDARD "Standar"
|
||||
IDS_TOOLBAR_TEST "Uji"
|
||||
IDS_IMAGE_NAME "Gambar %1!u!"
|
||||
IDS_FLT_TOOLS "Piranti"
|
||||
IDS_FLT_COLORS "Warna"
|
||||
IDS_FLT_HISTORY "Histori"
|
||||
END
|
||||
|
||||
/* imageprop.c */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_IMAGE_MONOCHROME "Monokrom (1 bit)"
|
||||
IDS_IMAGE_GREYSCALE "Abu-abu (8 bit)"
|
||||
IDS_IMAGE_PALETTE "Palet atau 256 warna (8 bit)"
|
||||
IDS_IMAGE_TRUECOLOR "Warna asli (24 bit)"
|
||||
|
||||
IDS_UNIT_PIXELS "Pixel"
|
||||
IDS_UNIT_CM "Cm"
|
||||
IDS_UNIT_INCHES "Inci"
|
||||
IDS_UNIT_DOTSCM "Dot / Cm"
|
||||
IDS_UNIT_DPI "DPI"
|
||||
IDS_UNIT_KB "%d KB"
|
||||
IDS_UNIT_MB "%d MB"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_TOOLTIP_NEW "Baru"
|
||||
IDS_TOOLTIP_OPEN "Buka"
|
||||
IDS_TOOLTIP_SAVE "Simpan"
|
||||
IDS_TOOLTIP_PRINTPRE "Tinjau cetakan"
|
||||
IDS_TOOLTIP_PRINT "Cetak"
|
||||
IDS_TOOLTIP_CUT "Cut"
|
||||
IDS_TOOLTIP_COPY "Copy"
|
||||
IDS_TOOLTIP_PASTE "Paste"
|
||||
IDS_TOOLTIP_UNDO "Undo"
|
||||
IDS_TOOLTIP_REDO "Redo"
|
||||
END
|
||||
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_BLANK " "
|
||||
IDS_HINT_NEW " Membuat dokumen baru."
|
||||
IDS_HINT_OPEN " Membuka dokumen yang sudah ada."
|
||||
IDS_HINT_CLOSE " Menutup jendela ini."
|
||||
IDS_HINT_CLOSEALL " Menutup semua jendela."
|
||||
IDS_HINT_SAVE " Menyimpan dokumen aktif."
|
||||
IDS_HINT_SAVEAS " Menyimpan dokumen aktif dengan nama baru."
|
||||
IDS_HINT_PRINTPRE " Meninjau dulu dokumen yang dicetak."
|
||||
IDS_HINT_PRINT " Mencetak dokumen aktif."
|
||||
IDS_HINT_PROP " Menampilkan properti gambar yang aktif."
|
||||
IDS_HINT_EXIT " Keluar aplikasi ini."
|
||||
|
||||
IDS_HINT_TOOLS " Menampilkan atau menyembunyikan jendela layang piranti."
|
||||
IDS_HINT_COLORS " Menampilkan atau menyembunyikan jendela layang warna."
|
||||
IDS_HINT_HISTORY " Menampilkan atau menyembunyikan jendela layang histori."
|
||||
IDS_HINT_STATUS " Menampilkan atau menyembunyikan bar status."
|
||||
|
||||
IDS_HINT_CASCADE " Mengatur jendela agar saling tindih."
|
||||
IDS_HINT_TILE_HORZ " Mengatur jendela seperti ubin tidak saling tindih."
|
||||
IDS_HINT_TILE_VERT " Mengatur jendela seperti ubin tidak saling tindih."
|
||||
IDS_HINT_ARRANGE " Mengatur ikon di bawah jendela."
|
||||
IDS_HINT_NEXT " Mengaktifkan jendela berikutnya."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " Mengembalikan jendela ini ke ukuran normal."
|
||||
IDS_HINT_SYS_MOVE " Memindahkan jendela ini."
|
||||
IDS_HINT_SYS_SIZE " Mengukur ulang jendela ini."
|
||||
IDS_HINT_SYS_MINIMIZE " Menyempitkan jendela ini menjadi ikon."
|
||||
IDS_HINT_SYS_MAXIMIZE " Melebarkan jendela ini memenuhi layar ini."
|
||||
END
|
234
rosapps/imagesoft/lang/it-IT.rc
Normal file
|
@ -0,0 +1,234 @@
|
|||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_VERSION "v0.1"
|
||||
END
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Nuovo...", ID_NEW
|
||||
MENUITEM "&Apri...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Chiudi\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "C&hiudi tutto", ID_CLOSEALL,GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Salva", ID_SAVE, GRAYED
|
||||
MENUITEM "Salva Co&me...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Ant&eprima di stampa", ID_PRINTPRE,GRAYED
|
||||
MENUITEM "S&tampa...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Pr&oprietà...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Esci\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "&Modifica"
|
||||
BEGIN
|
||||
MENUITEM "&Undo", ID_UNDO, GRAYED
|
||||
MENUITEM "&Redo", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Taglia", ID_CUT, GRAYED
|
||||
MENUITEM "&Copia", ID_COPY, GRAYED
|
||||
MENUITEM "&Incolla", ID_PASTE, GRAYED
|
||||
MENUITEM "Incolla come &nuova immagine", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Seleziona tutto", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Strumenti", ID_TOOLS
|
||||
MENUITEM "&Colori", ID_COLOR
|
||||
MENUITEM "&Azioni", ID_HISTORY
|
||||
MENUITEM "&Barra di stato", ID_STATUSBAR
|
||||
END
|
||||
POPUP "&Adjust"
|
||||
BEGIN
|
||||
MENUITEM "Luminosità...", ID_BRIGHTNESS
|
||||
MENUITEM "Contrasto...", ID_CONTRAST
|
||||
MENUITEM "Hue/Saturatione...", -1, GRAYED
|
||||
POPUP "Colore"
|
||||
BEGIN
|
||||
MENUITEM "Bianco e nero" ID_BLACKANDWHITE
|
||||
MENUITEM "Inveri i colori" ID_INVERTCOLORS
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Soffuso", ID_BLUR
|
||||
MENUITEM "Nitido", ID_SHARPEN
|
||||
MENUITEM "Bordi arrotondati", -1, GRAYED
|
||||
MENUITEM "Ombra", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Dimensione immagine...", -1, GRAYED
|
||||
MENUITEM "Ribalta", -1, GRAYED
|
||||
MENUITEM "Specchio", -1, GRAYED
|
||||
MENUITEM "Ruota", -1, GRAYED
|
||||
|
||||
END
|
||||
POPUP "&Colori"
|
||||
BEGIN
|
||||
MENUITEM "&Modifica i colori...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "&Finestre"
|
||||
BEGIN
|
||||
MENUITEM "&Sovrapponi", ID_WINDOW_CASCADE
|
||||
MENUITEM "Affianca &Orizontalmente", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "Affianca &Verticalmente", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "&Disponi Icone", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Succ&essiva\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "&Aiuto"
|
||||
BEGIN
|
||||
MENUITEM "&Informazioni...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU
|
||||
BEGIN
|
||||
POPUP "popup"
|
||||
BEGIN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
IDD_BRIGHTNESS DIALOGEX 6, 5, 193, 120
|
||||
CAPTION "Luminosità"
|
||||
FONT 8,"MS Sans Serif", 0, 0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "", IDC_PICPREVIEW, 0, 1, 132, 96, SS_OWNERDRAW | SS_SUNKEN
|
||||
LTEXT "Tipo colore:", IDC_STATIC, 135, 5, 36, 9
|
||||
GROUPBOX "", IDC_BRI_GROUP, 138 ,30, 50, 48
|
||||
CONTROL "Full (RGB)", IDC_BRI_FULL, "Button", BS_AUTORADIOBUTTON, 138, 18, 46, 9
|
||||
CONTROL "Rosso", IDC_BRI_RED, "Button", BS_AUTORADIOBUTTON, 142, 38, 42, 9
|
||||
CONTROL "Verde", IDC_BRI_GREEN, "Button", BS_AUTORADIOBUTTON, 142, 51, 42, 9
|
||||
CONTROL "Blu", IDC_BRI_BLUE, "Button", BS_AUTORADIOBUTTON, 142, 64, 42, 9
|
||||
EDITTEXT IDC_BRI_EDIT, 98, 103, 28, 13
|
||||
CONTROL "", IDC_BRI_TRACKBAR, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 2, 105, 90, 11
|
||||
PUSHBUTTON "OK", IDOK, 142, 88, 48, 13
|
||||
PUSHBUTTON "Annulla", IDCANCEL, 142, 105, 48, 13
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22,16,210,182
|
||||
CAPTION "Informazioni su ImageSoft"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
//EXSTYLE WS_EX_LAYERED
|
||||
BEGIN
|
||||
LTEXT "ImageSoft v0.1\nCopyright (C) 2006\nThomas Weidenmueller (w3seek@reactos.org)\nGed Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 150, 36
|
||||
PUSHBUTTON "Chiudi", IDOK, 75, 162, 44, 15
|
||||
ICON IDI_IMAGESOFTICON, IDC_STATIC, 10, 10, 7, 30
|
||||
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE
|
||||
END
|
||||
|
||||
|
||||
IDD_IMAGE_PROP DIALOGEX 6, 5, 156, 163
|
||||
CAPTION "Proprietà dell'immagine"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "Nome:", IDC_STATIC, 12, 5, 38, 9
|
||||
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||
GROUPBOX "Proprietà Canvas", IDC_STATIC, 4, 22, 148, 98
|
||||
LTEXT "Tipo immagine:", IDC_STATIC, 12, 36, 42, 9
|
||||
CONTROL "", IDC_IMAGETYPE, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
|
||||
LTEXT "Larghezza:", IDC_STATIC, 12, 51, 42, 9
|
||||
EDITTEXT IDC_WIDTH_EDIT, 58, 49, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_WIDTH_STAT, 94, 51, 40, 9
|
||||
LTEXT "Altezza:", IDC_STATIC, 12, 68, 42, 9
|
||||
EDITTEXT IDC_HEIGHT_EDIT, 58, 66, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_HEIGHT_STAT, 94, 68, 40, 9
|
||||
LTEXT "Risoluzione:", IDC_STATIC, 12, 84, 42, 9
|
||||
EDITTEXT IDC_RES_EDIT, 58, 83, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_RES_STAT, 94, 84, 40, 9
|
||||
LTEXT "Unità:", IDC_STATIC, 12, 99, 42, 9
|
||||
CONTROL "", IDC_UNIT, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
|
||||
LTEXT "Dimensione:", IDC_STATIC, 12, 125, 42, 9
|
||||
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
|
||||
PUSHBUTTON "OK", IDOK, 50, 144, 48, 13
|
||||
PUSHBUTTON "Annulla", IDCANCEL, 102, 144, 48, 13
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LICENSE "Questo programma è software libero; puoi distribuirlo e/o modificarlo nei termini di licenza di 'GNU General Public License' come pubblicata dalla 'Free Software Foundation'; entrambe le versioni 2 della Licenza, o (a vostra scelta) qualunque versione successiva.\r\n\r\nQuesto programma è distribuito con l'augurio che sia utile, ma PRIVO DI OGNI GARANZIA; privo anche della garanzia implicita di VENDIBILITA' o ADEGUATEZZA PER UNO SPECIFICO USO. Vedi la 'GNU General Public License' per ulteriori dettagli.\r\n\r\nVoi dovreste aver ricevuto una copia della 'GNU General Public License' assieme a questo programma; se non è cosi' scrivete a 'Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA'."
|
||||
IDS_READY "Pronto."
|
||||
IDS_TOOLBAR_STANDARD "Standard"
|
||||
IDS_TOOLBAR_TEST "Test"
|
||||
IDS_IMAGE_NAME "Immagine %1!u!"
|
||||
IDS_FLT_TOOLS "Strumenti"
|
||||
IDS_FLT_COLORS "Colori"
|
||||
IDS_FLT_HISTORY "Azioni"
|
||||
END
|
||||
|
||||
/* imageprop.c */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_IMAGE_MONOCHROME "Monocromatico (1 bit)"
|
||||
IDS_IMAGE_GREYSCALE "Toni di grigio (8 bit)"
|
||||
IDS_IMAGE_PALETTE "Palette o 256 colori (8 bit)"
|
||||
IDS_IMAGE_TRUECOLOR "True color (24 bit)"
|
||||
|
||||
IDS_UNIT_PIXELS "Pixel"
|
||||
IDS_UNIT_CM "Cm"
|
||||
IDS_UNIT_INCHES "Inches"
|
||||
IDS_UNIT_DOTSCM "Dots / Cm"
|
||||
IDS_UNIT_DPI "DPI"
|
||||
IDS_UNIT_KB "%d KB"
|
||||
IDS_UNIT_MB "%d MB"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_TOOLTIP_NEW "Nuova"
|
||||
IDS_TOOLTIP_OPEN "Apri"
|
||||
IDS_TOOLTIP_SAVE "Salva"
|
||||
IDS_TOOLTIP_PRINTPRE "Anteprima di stampa"
|
||||
IDS_TOOLTIP_PRINT "stampa"
|
||||
IDS_TOOLTIP_CUT "Taglia"
|
||||
IDS_TOOLTIP_COPY "Copia"
|
||||
IDS_TOOLTIP_PASTE "Incolla"
|
||||
IDS_TOOLTIP_UNDO "Undo"
|
||||
IDS_TOOLTIP_REDO "Redo"
|
||||
END
|
||||
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_BLANK " "
|
||||
IDS_HINT_NEW " Crea un nuovo documento."
|
||||
IDS_HINT_OPEN " Apre un documento esistente."
|
||||
IDS_HINT_CLOSE " Chide questa finestra."
|
||||
IDS_HINT_CLOSEALL " Chiude tutte le finestre."
|
||||
IDS_HINT_SAVE " Salva il documento attivo."
|
||||
IDS_HINT_SAVEAS " Salva il documento attivo con un nuovo nome."
|
||||
IDS_HINT_PRINTPRE " Anteprima del documento stampato."
|
||||
IDS_HINT_PRINT " Stampa il documento attivo."
|
||||
IDS_HINT_PROP " Mostra le proprieta' dell'immagine attiva."
|
||||
IDS_HINT_EXIT " Chiude il programma."
|
||||
|
||||
IDS_HINT_TOOLS " Mostra o nasconde la finestra mobile degli strumenti."
|
||||
IDS_HINT_COLORS " Mostra o nasconde la finestra mobile dei colori."
|
||||
IDS_HINT_HISTORY " Mostra o nasconde la finestra mobile delle azioni."
|
||||
IDS_HINT_STATUS " Mostra o nasconde la barra di stato."
|
||||
|
||||
IDS_HINT_CASCADE " Dispone le finestre in modo che siano sovrapposte."
|
||||
IDS_HINT_TILE_HORZ " Dispone le finestre in modo che non siano sovrapposte."
|
||||
IDS_HINT_TILE_VERT " Dispone le finestre in modo che non siano sovrapposte."
|
||||
IDS_HINT_ARRANGE " Dispone le icone in basso nella finestra."
|
||||
IDS_HINT_NEXT " Attiva la finestra successiva."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " Ripristina la dimensione normale della finestra."
|
||||
IDS_HINT_SYS_MOVE " Muova la finestra."
|
||||
IDS_HINT_SYS_SIZE " Modifica la dimensione della finestra."
|
||||
IDS_HINT_SYS_MINIMIZE " Riduce la finestra a una icona."
|
||||
IDS_HINT_SYS_MAXIMIZE " Espande la finestra fino a riempire lo schermo."
|
||||
END
|
206
rosapps/imagesoft/lang/nb-NO.rc
Normal file
|
@ -0,0 +1,206 @@
|
|||
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_VERSION "v0.1"
|
||||
END
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&Fil"
|
||||
BEGIN
|
||||
MENUITEM "&Ny...", ID_NEW
|
||||
MENUITEM "&Åpne...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Lukk\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "L&ukk alt", ID_CLOSEALL, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Lagre", ID_SAVE, GRAYED
|
||||
MENUITEM "Lagre &som...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Utskrift &Forhåndsvisning", ID_PRINTPRE, GRAYED
|
||||
MENUITEM "&Utskrift...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&genskaper...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "A&vslutt\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "&Rediger"
|
||||
BEGIN
|
||||
MENUITEM "&Angre", ID_UNDO, GRAYED
|
||||
MENUITEM "&Gjenta", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Klipp &ut", ID_CUT, GRAYED
|
||||
MENUITEM "&Kopier", ID_COPY, GRAYED
|
||||
MENUITEM "&Lim inn", ID_PASTE, GRAYED
|
||||
MENUITEM "lim inn som ny &bilde", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Velg Alt", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "&Vis"
|
||||
BEGIN
|
||||
MENUITEM "&Vertøy", ID_TOOLS, CHECKED
|
||||
MENUITEM "&Farger", ID_COLOR, CHECKED
|
||||
MENUITEM "&Historie", ID_HISTORY, CHECKED
|
||||
MENUITEM "&Statuslinje", ID_STATUSBAR, CHECKED
|
||||
END
|
||||
POPUP "&Bilde"
|
||||
BEGIN
|
||||
MENUITEM "&Crop...", -1, GRAYED
|
||||
MENUITEM "&Endre størrelse ...", -1, GRAYED
|
||||
MENUITEM "R&oter ...", -1, GRAYED
|
||||
MENUITEM "&Flip...", -1, GRAYED
|
||||
MENUITEM "&Strekk...", -1, GRAYED
|
||||
MENUITEM "S&kew...", -1, GRAYED
|
||||
MENUITEM "&Inverter Farger", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Attributter...", -1, GRAYED
|
||||
END
|
||||
POPUP "&Farger"
|
||||
BEGIN
|
||||
MENUITEM "&Rediger farger...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "&vindu"
|
||||
BEGIN
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "Sorter &horisontalt", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "Sorter &vertikalt", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "&Ordne Ikoner", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Nes&te\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "&Hjelp"
|
||||
BEGIN
|
||||
MENUITEM "&Om...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU
|
||||
BEGIN
|
||||
POPUP "popup"
|
||||
BEGIN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22,16,210,182
|
||||
CAPTION "Om ImageSoft"
|
||||
FONT 8,"Tahoma",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
//EXSTYLE WS_EX_LAYERED
|
||||
BEGIN
|
||||
LTEXT "ImageSoft v0.1\nCopyright (C) 2006\nThomas Weidenmueller (w3seek@reactos.org)\nGed Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 150, 36
|
||||
PUSHBUTTON "Lukk", IDOK, 75, 162, 44, 15
|
||||
ICON IDI_IMAGESOFTICON, IDC_STATIC, 10, 10, 7, 30
|
||||
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE
|
||||
END
|
||||
|
||||
|
||||
IDD_IMAGE_PROP DIALOGEX 6, 5, 156, 163
|
||||
CAPTION "Bilde egenskaper"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "Navn:", IDC_STATIC, 12, 5, 38, 9
|
||||
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||
GROUPBOX "maleri egenskaper", IDC_STATIC, 4, 22, 148, 98
|
||||
LTEXT "bilde type:", IDC_STATIC, 12, 36, 42, 9
|
||||
CONTROL "", IDC_IMAGETYPE, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
|
||||
LTEXT "Lengde:", IDC_STATIC, 12, 51, 42, 9
|
||||
EDITTEXT IDC_WIDTH_EDIT, 58, 49, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_WIDTH_STAT, 94, 51, 40, 9
|
||||
LTEXT "Høyde:", IDC_STATIC, 12, 68, 42, 9
|
||||
EDITTEXT IDC_HEIGHT_EDIT, 58, 66, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_HEIGHT_STAT, 94, 68, 40, 9
|
||||
LTEXT "Oppløsning:", IDC_STATIC, 12, 84, 42, 9
|
||||
EDITTEXT IDC_RES_EDIT, 58, 83, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_RES_STAT, 94, 84, 40, 9
|
||||
LTEXT "Enhet:", IDC_STATIC, 12, 99, 42, 9
|
||||
CONTROL "", IDC_UNIT, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
|
||||
LTEXT "bilde størrelse:", IDC_STATIC, 12, 125, 42, 9
|
||||
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
|
||||
PUSHBUTTON "OK", IDOK, 50, 144, 48, 13
|
||||
PUSHBUTTON "Avbryt", IDCANCEL, 102, 144, 48, 13
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
|
||||
IDS_READY " Klart."
|
||||
IDS_TOOLBAR_STANDARD "Standard"
|
||||
IDS_TOOLBAR_TEST "Test"
|
||||
IDS_IMAGE_NAME "Bilde %1!u!"
|
||||
IDS_FLT_TOOLS "Verktøy"
|
||||
IDS_FLT_COLORS "Farger"
|
||||
IDS_FLT_HISTORY "Historie"
|
||||
END
|
||||
|
||||
/* imageprop.c */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_IMAGE_MONOCHROME "Monokromt (1 bit)"
|
||||
IDS_IMAGE_GREYSCALE "Gråverdiskala (8 bit)"
|
||||
IDS_IMAGE_PALETTE "Palett eller 256 farger (8 bit)"
|
||||
IDS_IMAGE_TRUECOLOR "Nøyaktig farger (24 bit)"
|
||||
|
||||
IDS_UNIT_PIXELS "pikseler"
|
||||
IDS_UNIT_CM "Cm"
|
||||
IDS_UNIT_INCHES "tommer"
|
||||
IDS_UNIT_DOTSCM "Tommer / Cm"
|
||||
IDS_UNIT_DPI "DPI"
|
||||
IDS_UNIT_KB "%d KB"
|
||||
IDS_UNIT_MB "%d MB"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_TOOLTIP_NEW "Ny"
|
||||
IDS_TOOLTIP_OPEN "Åpne"
|
||||
IDS_TOOLTIP_SAVE "Lagre"
|
||||
IDS_TOOLTIP_PRINTPRE "Utskrift &Forhåndsvisning"
|
||||
IDS_TOOLTIP_PRINT "Utskrift"
|
||||
IDS_TOOLTIP_CUT "Klipp ut"
|
||||
IDS_TOOLTIP_COPY "Kopier"
|
||||
IDS_TOOLTIP_PASTE "Lim inn"
|
||||
IDS_TOOLTIP_UNDO "Angre"
|
||||
IDS_TOOLTIP_REDO "Gjenta"
|
||||
END
|
||||
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_BLANK " "
|
||||
IDS_HINT_NEW " Åpne et nytt dokument."
|
||||
IDS_HINT_OPEN " Åpene en eksisterende dokument."
|
||||
IDS_HINT_CLOSE " Lukk dette vinduet."
|
||||
IDS_HINT_CLOSEALL " Lukk alle vinduer."
|
||||
IDS_HINT_SAVE " Lagre aktive dokument."
|
||||
IDS_HINT_SAVEAS " Lagre aktive dokument med nytt navn."
|
||||
IDS_HINT_PRINTPRE " Forhåndsvis utskrift."
|
||||
IDS_HINT_PRINT " Skriv ut aktive dokument."
|
||||
IDS_HINT_PROP " Vis egenskaper for aktive bilde."
|
||||
IDS_HINT_EXIT " Avslutt denne applikasjonen."
|
||||
|
||||
IDS_HINT_TOOLS " Vis eller skjul verktøy floating vindu."
|
||||
IDS_HINT_COLORS " Vis eller skjul fargene floating vindu."
|
||||
IDS_HINT_HISTORY " Vis eller skjul historie floating vindu."
|
||||
IDS_HINT_STATUS " Vis eller skjul statuslinje."
|
||||
|
||||
IDS_HINT_CASCADE " Ordne vinduer så de overlapper."
|
||||
IDS_HINT_TILE_HORZ " Ordne vinduer så ingen-overlapper tittelen."
|
||||
IDS_HINT_TILE_VERT " Ordne vinduer så ingen-overlapper tittelen."
|
||||
IDS_HINT_ARRANGE " Ordne ikoner ved knappen av vinduet."
|
||||
IDS_HINT_NEXT " Aktivere neste vinduet."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " Endre vinduet til normal størrelse."
|
||||
IDS_HINT_SYS_MOVE " Flytt vinduet."
|
||||
IDS_HINT_SYS_SIZE " Endre størrelse på dette vinduet."
|
||||
IDS_HINT_SYS_MINIMIZE " Minimer vinduet til en ikon."
|
||||
IDS_HINT_SYS_MAXIMIZE " Expands dette vindu for å fylle skjermen."
|
||||
END
|
234
rosapps/imagesoft/lang/th-TH.rc
Normal file
|
@ -0,0 +1,234 @@
|
|||
LANGUAGE LANG_THAI, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_VERSION "v0.1"
|
||||
END
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "á&¿éÁ"
|
||||
BEGIN
|
||||
MENUITEM "ã&ËÁè...", ID_NEW
|
||||
MENUITEM "à&»Ô´...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "»Ô&´\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "»Ô´&·Ñé§ËÁ´", ID_CLOSEALL,GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&ºÑ¹·Ö¡", ID_SAVE, GRAYED
|
||||
MENUITEM "ºÑ¹&·Ö¡ à»ç¹...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&ÀÒ¾¡è͹¾ÔÁ¾ì", ID_PRINTPRE,GRAYED
|
||||
MENUITEM "&¾ÔÁ¾ì...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&¤Ø³ÊÁºÑµÔ...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&ÍÍ¡¨Ò¡â»Ãá¡ÃÁ\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "á&¡éä¢"
|
||||
BEGIN
|
||||
MENUITEM "à&ÅÔ¡·Ó", ID_UNDO, GRAYED
|
||||
MENUITEM "&Âé͹¡ÅѺ", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&µÑ´", ID_CUT, GRAYED
|
||||
MENUITEM "&¤Ñ´ÅÍ¡", ID_COPY, GRAYED
|
||||
MENUITEM "&ÇÒ§", ID_PASTE, GRAYED
|
||||
MENUITEM "ÇÒ&§à»ç¹ÀÒ¾ãËÁè", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "àÅ×Í¡·Ñé§ËÁ&´", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "&ÁØÁÁͧ"
|
||||
BEGIN
|
||||
MENUITEM "à¤Ã×èͧÁ×&Í", ID_TOOLS
|
||||
MENUITEM "&ÊÕ", ID_COLOR
|
||||
MENUITEM "&»ÃÐÇѵÔ", ID_HISTORY
|
||||
MENUITEM "á&¶ºÊ¶Ò¹Ð", ID_STATUSBAR
|
||||
END
|
||||
POPUP "&»ÃѺáµè§"
|
||||
BEGIN
|
||||
MENUITEM "¤ÇÒÁÊÇèÒ§...", ID_BRIGHTNESS
|
||||
MENUITEM "¤ÇÒÁªÑ´...", ID_CONTRAST
|
||||
MENUITEM "¤ÇÒÁà¢éÁáʧ/¤ÇÒÁÍÔèÁµÑÇ...", -1, GRAYED
|
||||
POPUP "ÊÕ"
|
||||
BEGIN
|
||||
MENUITEM "ÀÒ¾¢ÒÇ´Ó" ID_BLACKANDWHITE
|
||||
MENUITEM "á»Å§ÊÕ" ID_INVERTCOLORS
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "·ÓãËéÁÑÇ", ID_BLUR
|
||||
MENUITEM "·ÓãËé¤ÁªÑ´", ID_SHARPEN
|
||||
MENUITEM "·ÓãËé¢Íº¹ØèÁ", -1, GRAYED
|
||||
MENUITEM "à¾ÔèÁà§Ò", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "¢¹Ò´ÀÒ¾...", -1, GRAYED
|
||||
MENUITEM "¡ÅѺ·ÔÈ·Ò§", -1, GRAYED
|
||||
MENUITEM "¡ÅѺ´éÒ¹", -1, GRAYED
|
||||
MENUITEM "ËÁع", -1, GRAYED
|
||||
|
||||
END
|
||||
POPUP "&ÊÕ"
|
||||
BEGIN
|
||||
MENUITEM "á¡éä&¢ÊÕ...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "&˹éÒµèÒ§"
|
||||
BEGIN
|
||||
MENUITEM "&«é͹¡Ñ¹", ID_WINDOW_CASCADE
|
||||
MENUITEM "ÇÒ§àÃÕ§á¹Ç&¹Í¹", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "ÇÒ§àÃÕ§á¹Ç&µÑé§", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "¨Ñ´àÃÕ§ÊÑ&ÃÙ»", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&¶Ñ´ä»\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "&ªèÇÂàËÅ×Í"
|
||||
BEGIN
|
||||
MENUITEM "&à¡ÕèÂǡѺ...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU
|
||||
BEGIN
|
||||
POPUP "à»Ô´Ë¹éÒµèÒ§ãËÁè"
|
||||
BEGIN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
IDD_BRIGHTNESS DIALOGEX 6, 5, 193, 120
|
||||
CAPTION "¤ÇÒÁÊÇèÒ§"
|
||||
FONT 8,"MS Sans Serif", 0, 0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "", IDC_PICPREVIEW, 0, 1, 132, 96, SS_OWNERDRAW | SS_SUNKEN
|
||||
LTEXT "ÃٻẺÊÕ:", IDC_STATIC, 135, 5, 36, 9
|
||||
GROUPBOX "", IDC_BRI_GROUP, 138 ,30, 50, 48
|
||||
CONTROL "·Ø¡ÊÕ (RGB)", IDC_BRI_FULL, "»ØèÁ¡´", BS_AUTORADIOBUTTON, 138, 18, 46, 9
|
||||
CONTROL "á´§", IDC_BRI_RED, "Button", BS_AUTORADIOBUTTON, 142, 38, 42, 9
|
||||
CONTROL "à¢ÕÂÇ", IDC_BRI_GREEN, "»ØèÁ¡´", BS_AUTORADIOBUTTON, 142, 51, 42, 9
|
||||
CONTROL "¹éÓà§Ô¹", IDC_BRI_BLUE, "»ØèÁ¡´", BS_AUTORADIOBUTTON, 142, 64, 42, 9
|
||||
EDITTEXT IDC_BRI_EDIT, 98, 103, 28, 13
|
||||
CONTROL "", IDC_BRI_TRACKBAR, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 2, 105, 90, 11
|
||||
PUSHBUTTON "µ¡Å§", IDOK, 142, 88, 48, 13
|
||||
PUSHBUTTON "¡àÅÔ¡", IDCANCEL, 142, 105, 48, 13
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22,16,210,182
|
||||
CAPTION "à¡ÕèÂǡѺâ»Ãá¡ÃÁ ImageSoft"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
//EXSTYLE WS_EX_LAYERED
|
||||
BEGIN
|
||||
LTEXT "ImageSoft v0.1\nCopyright (C) 2006\nThomas Weidenmueller (w3seek@reactos.org)\nGed Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 150, 36
|
||||
PUSHBUTTON "»Ô´", IDOK, 75, 162, 44, 15
|
||||
ICON IDI_IMAGESOFTICON, IDC_STATIC, 10, 10, 7, 30
|
||||
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE
|
||||
END
|
||||
|
||||
|
||||
IDD_IMAGE_PROP DIALOGEX 6, 5, 156, 163
|
||||
CAPTION "¤Ø³ÊÁºÑµÔ¢Í§ÀÒ¾"
|
||||
FONT 8,"MS Sans Serif",0,0
|
||||
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
|
||||
BEGIN
|
||||
LTEXT "ª×èÍ:", IDC_STATIC, 12, 5, 38, 9
|
||||
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||
GROUPBOX "¤Ø³ÊÁºÑµÔ¢Í§¢¹Ò´¾×é¹·ÕèÀÒ¾", IDC_STATIC, 4, 22, 148, 98
|
||||
LTEXT "»ÃÐàÀ·ÃÙ»ÀÒ¾:", IDC_STATIC, 12, 36, 42, 9
|
||||
CONTROL "", IDC_IMAGETYPE, "¡Åèͧà¤Ã×èͧÁ×Í", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
|
||||
LTEXT "¤ÇÒÁ¡ÇéÒ§:", IDC_STATIC, 12, 51, 42, 9
|
||||
EDITTEXT IDC_WIDTH_EDIT, 58, 49, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_WIDTH_STAT, 94, 51, 40, 9
|
||||
LTEXT "¤ÇÒÁÊÙ§:", IDC_STATIC, 12, 68, 42, 9
|
||||
EDITTEXT IDC_HEIGHT_EDIT, 58, 66, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_HEIGHT_STAT, 94, 68, 40, 9
|
||||
LTEXT "¤ÇÒÁÅÐàÍÕ´¢Í§ÀÒ¾:", IDC_STATIC, 12, 84, 42, 9
|
||||
EDITTEXT IDC_RES_EDIT, 58, 83, 32, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER
|
||||
LTEXT "", IDC_RES_STAT, 94, 84, 40, 9
|
||||
LTEXT "˹èÇÂ:", IDC_STATIC, 12, 99, 42, 9
|
||||
CONTROL "", IDC_UNIT, "¡Åèͧà¤Ã×èͧÁ×Í", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
|
||||
LTEXT "¢¹Ò´ÀÒ¾:", IDC_STATIC, 12, 125, 42, 9
|
||||
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
|
||||
PUSHBUTTON "µ¡Å§", IDOK, 50, 144, 48, 13
|
||||
PUSHBUTTON "¡àÅÔ¡", IDCANCEL, 102, 144, 48, 13
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
|
||||
IDS_READY " àÊÃç¨áÅéÇ."
|
||||
IDS_TOOLBAR_STANDARD "Áҵðҹ"
|
||||
IDS_TOOLBAR_TEST "·´Êͺ"
|
||||
IDS_IMAGE_NAME "ÀÒ¾ %1!u!"
|
||||
IDS_FLT_TOOLS "à¤Ã×èͧÁ×Í"
|
||||
IDS_FLT_COLORS "ÊÕ"
|
||||
IDS_FLT_HISTORY "»ÃÐÇѵÔ"
|
||||
END
|
||||
|
||||
/* imageprop.c */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_IMAGE_MONOCHROME "ÊÕà´ÕÂÇ (1 bit)"
|
||||
IDS_IMAGE_GREYSCALE "ÀÒ¾¢ÒÇ´Ó (8 bit)"
|
||||
IDS_IMAGE_PALETTE "ᶺÊÕ 256 ÊÕ (8 bit)"
|
||||
IDS_IMAGE_TRUECOLOR "ÊÕ¨ÃÔ§ (24 bit)"
|
||||
|
||||
IDS_UNIT_PIXELS "àÁç´ÊÕ"
|
||||
IDS_UNIT_CM "ૹµÔàÁµÃ"
|
||||
IDS_UNIT_INCHES "¹ÔéÇ"
|
||||
IDS_UNIT_DOTSCM "¨Ø´ / ૹµÔàÁµÃ"
|
||||
IDS_UNIT_DPI "¨Ø´µè͹ÔéÇ"
|
||||
IDS_UNIT_KB "%d ¡ÔâÅ亵ì"
|
||||
IDS_UNIT_MB "%d àÁ¡¡Ð亵ì"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_TOOLTIP_NEW "ãËÁè"
|
||||
IDS_TOOLTIP_OPEN "à»Ô´"
|
||||
IDS_TOOLTIP_SAVE "ºÑ¹·Ö¡"
|
||||
IDS_TOOLTIP_PRINTPRE "ÀÒ¾¡è͹¾ÔÁ¾ì"
|
||||
IDS_TOOLTIP_PRINT "¾ÔÁ¾ì"
|
||||
IDS_TOOLTIP_CUT "µÑ´"
|
||||
IDS_TOOLTIP_COPY "¤Ñ´ÅÍ¡"
|
||||
IDS_TOOLTIP_PASTE "ÇÒ§"
|
||||
IDS_TOOLTIP_UNDO "àÅÔ¡·Ó"
|
||||
IDS_TOOLTIP_REDO "Âé͹¡ÅѺ"
|
||||
END
|
||||
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_BLANK " "
|
||||
IDS_HINT_NEW " ÊÃéÒ§àÍ¡ÊÒÃãËÁè."
|
||||
IDS_HINT_OPEN " à»Ô´àÍ¡ÊÒ÷ÕèÁÕÍÂÙè."
|
||||
IDS_HINT_CLOSE " »Ô´Ë¹éÒµèÒ§¹Õé."
|
||||
IDS_HINT_CLOSEALL " »Ô´Ë¹éÒµèÒ§·Ñé§ËÁ´."
|
||||
IDS_HINT_SAVE " ºÑ¹·Ö¡àÍ¡ÊÒ÷Õèà¡çºäÇé."
|
||||
IDS_HINT_SAVEAS " ºÑ¹·Ö¡àÍ¡ÊÒ÷Õè¡ÓÅѧ·ÓÍÂÙè´éǪ×èÍãËÁè."
|
||||
IDS_HINT_PRINTPRE " ÁͧÀÒ¾¡è͹¾ÔÁ¾ì¢Í§àÍ¡ÊÒÃ."
|
||||
IDS_HINT_PRINT " ¾ÔÁ¾ìàÍ¡ÊÒ÷Õè¡ÓÅѧ·ÓÍÂÙè¹Õé."
|
||||
IDS_HINT_PROP " áÊ´§¤Ø³ÊÁºÑµÔ¢Í§ÀÒ¾·Õè¡ÓÅѧ·ÓÍÂÙè¹Õé."
|
||||
IDS_HINT_EXIT " ÍÍ¡¨Ò¡¡Ò÷ӧҹ."
|
||||
|
||||
IDS_HINT_TOOLS " áÊ´§Ë¹éÒ«è͹˹éÒµèÒ§¢Í§á¶ºà¤Ã×èͧÁ×Í."
|
||||
IDS_HINT_COLORS " áÊ´§Ë¹éÒ«è͹˹éÒµèÒ§¢Í§á¶ºÊÕ."
|
||||
IDS_HINT_HISTORY " áÊ´§Ë¹éÒ«è͹˹éÒµèÒ§¢Í§á¶º»ÃÐÇѵÔ."
|
||||
IDS_HINT_STATUS " áÊ´§Ë¹éÒ«è͹˹éÒµèÒ§¢Í§á¶ºÊ¶Ò¹Ð."
|
||||
|
||||
IDS_HINT_CASCADE " àÃÕ§˹éÒµèÒ§ÇÒ§«é͹¡Ñ¹."
|
||||
IDS_HINT_TILE_HORZ " àÃÕ§˹éÒµèÒ§µÒÁá¹Ç¹Í¹."
|
||||
IDS_HINT_TILE_VERT " àÃÕ§˹éÒµèÒ§µÒÁá¹ÇµÑé§."
|
||||
IDS_HINT_ARRANGE " ¨Ñ´àÃÕ§ÊÑÃÙ»·Õè´éÒ¹ÅèÒ§¢Í§Ë¹éÒµèÒ§."
|
||||
IDS_HINT_NEXT " àÃÔèÁ·Ó§Ò¹Ë¹éÒµèÒ§¶Ñ´ä»."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " ¤×¹ÊÀҾ˹éÒµèÒ§ÊÙ袹Ҵ»¡µÔ."
|
||||
IDS_HINT_SYS_MOVE " à¤Å×è͹ÂéÒÂ˹éÒµèÒ§¹Õé."
|
||||
IDS_HINT_SYS_SIZE " à»ÅÕè¹¢¹Ò´Ë¹éÒµèÒ§¹Õé."
|
||||
IDS_HINT_SYS_MINIMIZE " ÂèÍ˹éÒµèÒ§¹ÕéãËéà»ç¹ÊÑÃÙ»."
|
||||
IDS_HINT_SYS_MAXIMIZE " ¢ÂÒÂ˹éÒµèÒ§¹Õ騹àµçÁ˹éÒ¨Í."
|
||||
END
|
1458
rosapps/imagesoft/mainwnd.c
Normal file
41
rosapps/imagesoft/mainwnd.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
|
||||
typedef struct _MENU_HINT
|
||||
{
|
||||
WORD CmdId;
|
||||
UINT HintId;
|
||||
} MENU_HINT, *PMENU_HINT;
|
||||
|
||||
typedef struct _MAIN_WND_INFO
|
||||
{
|
||||
HWND hSelf;
|
||||
HWND hMdiClient;
|
||||
HWND hStatus;
|
||||
int nCmdShow;
|
||||
|
||||
struct _FLT_WND *fltTools;
|
||||
struct _FLT_WND *fltColors;
|
||||
struct _FLT_WND *fltHistory;
|
||||
|
||||
struct _TOOLBAR_DOCKS ToolDocks;
|
||||
|
||||
/* Editors */
|
||||
PEDIT_WND_INFO ImageEditors;
|
||||
UINT ImagesCreated;
|
||||
|
||||
PVOID ActiveEditor;
|
||||
|
||||
/* status flags */
|
||||
BOOL InMenuLoop : 1;
|
||||
} MAIN_WND_INFO, *PMAIN_WND_INFO;
|
||||
|
||||
BOOL InitMainWindowImpl(VOID);
|
||||
VOID UninitMainWindowImpl(VOID);
|
||||
HWND CreateMainWindow(LPCTSTR lpCaption,
|
||||
int nCmdShow);
|
||||
BOOL MainWndTranslateMDISysAccel(HWND hwnd,
|
||||
LPMSG lpMsg);
|
||||
VOID MainWndSwitchEditorContext(PMAIN_WND_INFO Info,
|
||||
HWND hDeactivate,
|
||||
HWND hActivate);
|
||||
MDI_EDITOR_TYPE MainWndGetCurrentEditor(PMAIN_WND_INFO MainWnd,
|
||||
PVOID *Info);
|
24
rosapps/imagesoft/manifest.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
name="ReactOS.VMware.SVGA.Installer"
|
||||
type="win32"
|
||||
/>
|
||||
<description>ReactOS VMware(r) SVGA driver Installer</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
|
||||
<!-- EOF -->
|
422
rosapps/imagesoft/misc.c
Normal file
|
@ -0,0 +1,422 @@
|
|||
#include <precomp.h>
|
||||
|
||||
static INT
|
||||
LengthOfStrResource(IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
{
|
||||
HRSRC hrSrc;
|
||||
HGLOBAL hRes;
|
||||
LPWSTR lpName, lpStr;
|
||||
|
||||
if (hInst == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* There are always blocks of 16 strings */
|
||||
lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
|
||||
|
||||
/* Find the string table block */
|
||||
if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
|
||||
(hRes = LoadResource(hInst, hrSrc)) &&
|
||||
(lpStr = LockResource(hRes)))
|
||||
{
|
||||
UINT x;
|
||||
|
||||
/* Find the string we're looking for */
|
||||
uID &= 0xF; /* position in the block, same as % 16 */
|
||||
for (x = 0; x < uID; x++)
|
||||
{
|
||||
lpStr += (*lpStr) + 1;
|
||||
}
|
||||
|
||||
/* Found the string */
|
||||
return (int)(*lpStr);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
INT
|
||||
AllocAndLoadString(OUT LPTSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
{
|
||||
INT ln;
|
||||
|
||||
ln = LengthOfStrResource(hInst,
|
||||
uID);
|
||||
if (ln++ > 0)
|
||||
{
|
||||
(*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
|
||||
ln * sizeof(TCHAR));
|
||||
if ((*lpTarget) != NULL)
|
||||
{
|
||||
INT Ret;
|
||||
if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
|
||||
{
|
||||
LocalFree((HLOCAL)(*lpTarget));
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
LoadAndFormatString(IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
OUT LPTSTR *lpTarget,
|
||||
...)
|
||||
{
|
||||
DWORD Ret = 0;
|
||||
LPTSTR lpFormat;
|
||||
va_list lArgs;
|
||||
|
||||
if (AllocAndLoadString(&lpFormat,
|
||||
hInstance,
|
||||
uID) > 0)
|
||||
{
|
||||
va_start(lArgs, lpTarget);
|
||||
/* let's use FormatMessage to format it because it has the ability to allocate
|
||||
memory automatically */
|
||||
Ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
|
||||
lpFormat,
|
||||
0,
|
||||
0,
|
||||
(LPTSTR)lpTarget,
|
||||
0,
|
||||
&lArgs);
|
||||
va_end(lArgs);
|
||||
|
||||
LocalFree((HLOCAL)lpFormat);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
BOOL
|
||||
StatusBarLoadAndFormatString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
...)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
LPTSTR lpFormat, lpStr;
|
||||
va_list lArgs;
|
||||
|
||||
if (AllocAndLoadString(&lpFormat,
|
||||
hInstance,
|
||||
uID) > 0)
|
||||
{
|
||||
va_start(lArgs, uID);
|
||||
/* let's use FormatMessage to format it because it has the ability to allocate
|
||||
memory automatically */
|
||||
Ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
|
||||
lpFormat,
|
||||
0,
|
||||
0,
|
||||
(LPTSTR)&lpStr,
|
||||
0,
|
||||
&lArgs);
|
||||
va_end(lArgs);
|
||||
|
||||
if (lpStr != NULL)
|
||||
{
|
||||
Ret = (BOOL)SendMessage(hStatusBar,
|
||||
SB_SETTEXT,
|
||||
(WPARAM)PartId,
|
||||
(LPARAM)lpStr);
|
||||
LocalFree((HLOCAL)lpStr);
|
||||
}
|
||||
|
||||
LocalFree((HLOCAL)lpFormat);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
BOOL
|
||||
StatusBarLoadString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
LPTSTR lpStr;
|
||||
|
||||
if (AllocAndLoadString(&lpStr,
|
||||
hInstance,
|
||||
uID) > 0)
|
||||
{
|
||||
Ret = (BOOL)SendMessage(hStatusBar,
|
||||
SB_SETTEXT,
|
||||
(WPARAM)PartId,
|
||||
(LPARAM)lpStr);
|
||||
LocalFree((HLOCAL)lpStr);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
INT
|
||||
GetTextFromEdit(OUT LPTSTR lpString,
|
||||
IN HWND hDlg,
|
||||
IN UINT Res)
|
||||
{
|
||||
INT len = GetWindowTextLength(GetDlgItem(hDlg, Res));
|
||||
if(len > 0)
|
||||
{
|
||||
GetDlgItemText(hDlg,
|
||||
Res,
|
||||
lpString,
|
||||
len + 1);
|
||||
}
|
||||
else
|
||||
lpString = NULL;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
VOID GetError(DWORD err)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
|
||||
if (err == 0)
|
||||
err = GetLastError();
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
err,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL );
|
||||
|
||||
MessageBox(NULL, lpMsgBuf, _T("Error!"), MB_OK | MB_ICONERROR);
|
||||
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Toolbar custom control routines
|
||||
*/
|
||||
|
||||
typedef struct _TBCUSTCTL
|
||||
{
|
||||
HWND hWndControl;
|
||||
INT iCommand;
|
||||
BOOL HideVertical : 1;
|
||||
BOOL IsVertical : 1;
|
||||
} TBCUSTCTL, *PTBCUSTCTL;
|
||||
|
||||
BOOL
|
||||
ToolbarDeleteControlSpace(HWND hWndToolbar,
|
||||
const TBBUTTON *ptbButton)
|
||||
{
|
||||
if ((ptbButton->fsStyle & TBSTYLE_SEP) &&
|
||||
ptbButton->dwData != 0)
|
||||
{
|
||||
PTBCUSTCTL cctl = (PTBCUSTCTL)ptbButton->dwData;
|
||||
|
||||
DestroyWindow(cctl->hWndControl);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
cctl);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID
|
||||
ToolbarUpdateControlSpaces(HWND hWndToolbar,
|
||||
ToolbarChangeControlCallback ChangeCallback)
|
||||
{
|
||||
BOOL Vert;
|
||||
DWORD nButtons, i;
|
||||
TBBUTTON tbtn;
|
||||
|
||||
Vert = ((SendMessage(hWndToolbar,
|
||||
TB_GETSTYLE,
|
||||
0,
|
||||
0) & CCS_VERT) != 0);
|
||||
|
||||
nButtons = (DWORD)SendMessage(hWndToolbar,
|
||||
TB_BUTTONCOUNT,
|
||||
0,
|
||||
0);
|
||||
|
||||
for (i = 0;
|
||||
i != nButtons;
|
||||
i++)
|
||||
{
|
||||
if (SendMessage(hWndToolbar,
|
||||
TB_GETBUTTON,
|
||||
(WPARAM)i,
|
||||
(LPARAM)&tbtn))
|
||||
{
|
||||
if ((tbtn.fsStyle & TBSTYLE_SEP) && tbtn.dwData != 0)
|
||||
{
|
||||
PTBCUSTCTL cctl = (PTBCUSTCTL)tbtn.dwData;
|
||||
|
||||
cctl->IsVertical = Vert;
|
||||
|
||||
if (cctl->HideVertical)
|
||||
{
|
||||
ShowWindow(cctl->hWndControl,
|
||||
(Vert ? SW_HIDE : SW_SHOW));
|
||||
goto ShowHideSep;
|
||||
}
|
||||
else if (cctl->IsVertical != Vert)
|
||||
{
|
||||
ChangeCallback(hWndToolbar,
|
||||
cctl->hWndControl,
|
||||
Vert);
|
||||
|
||||
ShowHideSep:
|
||||
/* show/hide the separator */
|
||||
SendMessage(hWndToolbar,
|
||||
TB_HIDEBUTTON,
|
||||
(WPARAM)cctl->iCommand,
|
||||
(LPARAM)Vert && cctl->HideVertical);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
ToolbarInsertSpaceForControl(HWND hWndToolbar,
|
||||
HWND hWndControl,
|
||||
INT Index,
|
||||
INT iCmd,
|
||||
BOOL HideVertical)
|
||||
{
|
||||
PTBCUSTCTL cctl;
|
||||
RECT rcControl, rcItem;
|
||||
|
||||
cctl = HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
sizeof(TBCUSTCTL));
|
||||
if (cctl == NULL)
|
||||
return FALSE;
|
||||
|
||||
cctl->HideVertical = HideVertical;
|
||||
cctl->hWndControl = hWndControl;
|
||||
cctl->iCommand = iCmd;
|
||||
|
||||
if (GetWindowRect(hWndControl,
|
||||
&rcControl))
|
||||
{
|
||||
TBBUTTON tbtn = {0};
|
||||
|
||||
tbtn.iBitmap = rcControl.right - rcControl.left;
|
||||
tbtn.idCommand = iCmd;
|
||||
tbtn.fsStyle = TBSTYLE_SEP;
|
||||
tbtn.dwData = (DWORD_PTR)cctl;
|
||||
|
||||
if (SendMessage(hWndToolbar,
|
||||
TB_GETSTYLE,
|
||||
0,
|
||||
0) & CCS_VERT)
|
||||
{
|
||||
if (HideVertical)
|
||||
tbtn.fsState |= TBSTATE_HIDDEN;
|
||||
|
||||
cctl->IsVertical = TRUE;
|
||||
}
|
||||
else
|
||||
cctl->IsVertical = FALSE;
|
||||
|
||||
if (SendMessage(hWndToolbar,
|
||||
TB_INSERTBUTTON,
|
||||
(WPARAM)Index,
|
||||
(LPARAM)&tbtn))
|
||||
{
|
||||
if (SendMessage(hWndToolbar,
|
||||
TB_GETITEMRECT,
|
||||
(WPARAM)Index,
|
||||
(LPARAM)&rcItem))
|
||||
{
|
||||
SetWindowPos(hWndControl,
|
||||
NULL,
|
||||
rcItem.left,
|
||||
rcItem.top,
|
||||
rcItem.right - rcItem.left,
|
||||
rcItem.bottom - rcItem.top,
|
||||
SWP_NOZORDER);
|
||||
|
||||
ShowWindow(hWndControl,
|
||||
SW_SHOW);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (tbtn.fsState & TBSTATE_HIDDEN)
|
||||
{
|
||||
ShowWindow(hWndControl,
|
||||
SW_HIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
HIMAGELIST
|
||||
InitImageList(UINT NumImages, UINT StartResource)
|
||||
{
|
||||
HBITMAP hBitmap;
|
||||
HIMAGELIST hImageList;
|
||||
UINT i, k;
|
||||
INT Ret;
|
||||
|
||||
|
||||
/* Create the toolbar icon image list */
|
||||
hImageList = ImageList_Create(TB_BMP_WIDTH,
|
||||
TB_BMP_HEIGHT,
|
||||
ILC_MASK | ILC_COLOR24,
|
||||
NumImages,
|
||||
0);
|
||||
if (! hImageList)
|
||||
return NULL;
|
||||
|
||||
/* Add all icons to the image list */
|
||||
for (i = StartResource, k = 0; k < NumImages; i++, k++)
|
||||
{
|
||||
hBitmap = LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(i),
|
||||
IMAGE_BITMAP,
|
||||
TB_BMP_WIDTH,
|
||||
TB_BMP_HEIGHT,
|
||||
LR_LOADTRANSPARENT);
|
||||
|
||||
Ret = ImageList_AddMasked(hImageList,
|
||||
hBitmap,
|
||||
RGB(255, 255, 254));
|
||||
|
||||
DeleteObject(hBitmap);
|
||||
}
|
||||
|
||||
return hImageList;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
static BOOL
|
||||
DestroyImageList(HIMAGELIST hImageList)
|
||||
{
|
||||
if (! ImageList_Destroy(hImageList))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
44
rosapps/imagesoft/misc.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
INT AllocAndLoadString(OUT LPTSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
IN UINT uID);
|
||||
|
||||
DWORD LoadAndFormatString(IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
OUT LPTSTR *lpTarget,
|
||||
...);
|
||||
|
||||
BOOL StatusBarLoadAndFormatString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
...);
|
||||
|
||||
BOOL StatusBarLoadString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID);
|
||||
|
||||
INT GetTextFromEdit(OUT LPTSTR lpString,
|
||||
IN HWND hDlg,
|
||||
IN UINT Res);
|
||||
|
||||
VOID GetError(DWORD err);
|
||||
|
||||
BOOL ToolbarDeleteControlSpace(HWND hWndToolbar,
|
||||
const TBBUTTON *ptbButton);
|
||||
|
||||
typedef VOID (*ToolbarChangeControlCallback)(HWND hWndToolbar,
|
||||
HWND hWndControl,
|
||||
BOOL Vert);
|
||||
VOID ToolbarUpdateControlSpaces(HWND hWndToolbar,
|
||||
ToolbarChangeControlCallback ChangeCallback);
|
||||
|
||||
BOOL ToolbarInsertSpaceForControl(HWND hWndToolbar,
|
||||
HWND hWndControl,
|
||||
INT Index,
|
||||
INT iCmd,
|
||||
BOOL HideVertical);
|
||||
|
||||
HIMAGELIST InitImageList(UINT NumButtons,
|
||||
UINT StartResource);
|
87
rosapps/imagesoft/opensave.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include <precomp.h>
|
||||
|
||||
static OPENFILENAME ofn;
|
||||
|
||||
/*
|
||||
* Initialize file open / save structure
|
||||
*/
|
||||
VOID FileInitialize(HWND hwnd)
|
||||
{
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.nMaxFileTitle = MAX_PATH;
|
||||
ofn.lpstrDefExt = _T("bmp");
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
DoWriteFile(LPCTSTR pszFileName)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
DoOpenFile(HWND hwnd,
|
||||
LPTSTR szFileName,
|
||||
LPTSTR szTitleName)
|
||||
{
|
||||
DWORD err;
|
||||
/*static TCHAR Filter[] = _T("All image files (*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png)\0*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png\0") \
|
||||
_T("All files (*.*)\0*.*\0") \
|
||||
_T("Graphics Interchange format (*gif)\0*.gif\0") \
|
||||
_T("Windows Bitmap (*bmp)\0*.bmp\0") \
|
||||
_T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
|
||||
_T("TAG Image File Format (*tif)\0*.tif\0") \
|
||||
_T("Portable Network Graphics (*png)\0*.png\0\0");*/
|
||||
|
||||
static TCHAR Filter[] = _T("Windows Bitmap (*.bmp)\0*.bmp\0");
|
||||
|
||||
ofn.lpstrFilter = Filter;
|
||||
ofn.lpstrFile = szFileName;
|
||||
ofn.lpstrFileTitle = szTitleName;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
err = CommDlgExtendedError();
|
||||
|
||||
if (err != CDERR_GENERALCODES)
|
||||
MessageBox(NULL, _T("Open file failed"), NULL, 0);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL
|
||||
DoSaveFile(HWND hwnd)
|
||||
{
|
||||
TCHAR szFileName[MAX_PATH] = _T("");
|
||||
static TCHAR Filter[] = _T("Graphics Interchange format (*gif)\0*.gif\0") \
|
||||
_T("Windows Bitmap (*bmp)\0*.bmp\0") \
|
||||
_T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
|
||||
_T("TAG Image File Format (*tif)\0*.tif\0") \
|
||||
_T("Portable Network Graphics (*png)\0*.png\0\0");
|
||||
|
||||
ofn.lpstrFilter = Filter;
|
||||
ofn.lpstrFile = szFileName;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
||||
|
||||
if (GetSaveFileName(&ofn))
|
||||
{
|
||||
if (DoWriteFile(szFileName))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CommDlgExtendedError() != CDERR_GENERALCODES)
|
||||
MessageBox(NULL, _T("Save to file failed"), NULL, 0);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
70
rosapps/imagesoft/precomp.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
#ifndef __IMAGESOFT_PRECOMP_H
|
||||
#define __IMAGESOFT_PRECOMP_H
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include "resource.h"
|
||||
|
||||
#include "tooldock.h"
|
||||
#include "imgedwnd.h"
|
||||
#include "mainwnd.h"
|
||||
#include "imageprop.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define MAX_KEY_LENGTH 256
|
||||
#define NUM_MAINTB_IMAGES 10
|
||||
#define TB_BMP_WIDTH 16
|
||||
#define TB_BMP_HEIGHT 16
|
||||
|
||||
#define TOOLS 0
|
||||
#define COLORS 1
|
||||
#define HISTORY 2
|
||||
|
||||
extern HINSTANCE hInstance;
|
||||
extern HANDLE ProcessHeap;
|
||||
|
||||
/* about.c */
|
||||
INT_PTR CALLBACK AboutDialogProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
/* opensave.c */
|
||||
VOID FileInitialize(HWND hwnd);
|
||||
BOOL DoOpenFile(HWND hwnd,
|
||||
LPTSTR lpFileName,
|
||||
LPTSTR lpName);
|
||||
BOOL DoSaveFile(HWND hwnd);
|
||||
|
||||
/* floattoolbar.c */
|
||||
typedef struct _FLT_WND
|
||||
{
|
||||
HWND hSelf;
|
||||
LPTSTR lpName;
|
||||
INT x;
|
||||
INT y;
|
||||
INT Width;
|
||||
INT Height;
|
||||
INT Transparancy;
|
||||
BOOL bOpaque;
|
||||
} FLT_WND, *PFLT_WND;
|
||||
|
||||
BOOL FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info);
|
||||
BOOL FloatToolbarCreateColorsGui(PMAIN_WND_INFO Info);
|
||||
BOOL FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info);
|
||||
BOOL InitFloatWndClass(VOID);
|
||||
VOID UninitFloatWndImpl(VOID);
|
||||
BOOL ShowHideWindow(HWND hwnd);
|
||||
|
||||
/* font.c */
|
||||
VOID FillFontStyleComboList(HWND hwndCombo);
|
||||
VOID FillFontSizeComboList(HWND hwndCombo);
|
||||
|
||||
/* custcombo.c */
|
||||
VOID MakeFlatCombo(HWND hwndCombo);
|
||||
|
||||
#endif /* __IMAGESOFT_PRECOMP_H */
|
BIN
rosapps/imagesoft/res/cursors/PaintBrushToolCursor.cur
Normal file
After Width: | Height: | Size: 326 B |
BIN
rosapps/imagesoft/res/cursors/PaintBrushToolCursorMouseDown.cur
Normal file
After Width: | Height: | Size: 326 B |
BIN
rosapps/imagesoft/res/icons/color/ColorLess.bmp
Normal file
After Width: | Height: | Size: 670 B |
BIN
rosapps/imagesoft/res/icons/color/ColorMore.bmp
Normal file
After Width: | Height: | Size: 450 B |
BIN
rosapps/imagesoft/res/icons/hist/HistBack.bmp
Normal file
After Width: | Height: | Size: 824 B |