1
0
mirror of https://github.com/UzixLS/KernelEx.git synced 2025-07-19 07:21:20 +03:00

import KernelEx-4.5-Final

This commit is contained in:
UzixLS
2018-11-03 16:23:17 +03:00
parent 309977e788
commit 7571e3c60d
125 changed files with 11876 additions and 9943 deletions

1
util/sdbcreate/readme.txt Executable file
View File

@ -0,0 +1 @@
This program requires Windows NT 6.0 or higher to function.

17
util/sdbcreate/sdbapi.def Executable file
View File

@ -0,0 +1,17 @@
LIBRARY APPHELP.DLL
EXPORTS
SdbCreateDatabase
SdbDeclareIndex
SdbCloseDatabase
SdbCloseDatabaseWrite
SdbCommitIndexes
SdbStartIndexing
SdbStopIndexing
SdbBeginWriteListTag
SdbEndWriteListTag
SdbWriteBinaryTag
SdbWriteBinaryTagFromFile
SdbWriteStringTag
SdbWriteDWORDTag
SdbGUIDFromString

113
util/sdbcreate/sdbapi.h Executable file
View File

@ -0,0 +1,113 @@
/*
* KernelEx
* Copyright (C) 2010, Tihiy
*
* This file is part of KernelEx source code.
*
* KernelEx 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; version 2 of the License.
*
* KernelEx is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __SDBAPI_H
#define __SDBAPI_H
#include <windows.h>
#ifdef SDBAPI_IMPLIB
#ifdef _MSC_VER
#pragma warning(disable:4716)
#endif
#define MAKE_HEADER(decl) \
__declspec(dllexport) decl {}
#else
#define MAKE_HEADER(decl) \
__declspec(dllimport) decl ;
#endif
#ifdef __cplusplus
extern "C" {
#endif
//types
typedef PVOID PDB;
typedef DWORD INDEXID;
typedef DWORD TAGID;
typedef DWORD TAG;
//enums
typedef enum _PATH_TYPE {
DOS_PATH,
NT_PATH
} PATH_TYPE;
//tags
#define TAG_DWORD 0x4000
#define TAG_MSI_TRANSFORM_TAGID 0x401B
#define TAG_STRING 0x6000
#define TAG_NAME 0x6001
#define TAG_APP_NAME 0x6006
#define TAG_MSI_TRANSFORM_FILE 0x601F
#define TAG_COMPILER_VERSION 0x6022
#define TAG_LIST 0x7000
#define TAG_DATABASE 0x7001
#define TAG_LIBRARY 0x7002
#define TAG_FILE 0x700C
#define TAG_MSI_TRANSFORM 0x7010
#define TAG_MSI_TRANSFORM_REF 0x7011
#define TAG_MSI_PACKAGE 0x7012
#define TAG_BINARY 0x9000
#define TAG_FILE_BITS 0x9003
#define TAG_EXE_ID 0x9004
#define TAG_MSI_PACKAGE_ID 0x9006
#define TAG_DATABASE_ID 0x9007
//functions
MAKE_HEADER(PDB WINAPI SdbCreateDatabase(LPCWSTR pwszPath, PATH_TYPE eType))
MAKE_HEADER(void WINAPI SdbCloseDatabase(PDB pdb))
MAKE_HEADER(void WINAPI SdbCloseDatabaseWrite(PDB pdb))
MAKE_HEADER(BOOL WINAPI SdbDeclareIndex(PDB pdb,TAG tWhich,TAG tKey,DWORD dwEntries,BOOL bUniqueKey,INDEXID *piiIndex))
MAKE_HEADER(BOOL WINAPI SdbCommitIndexes(PDB pdb))
MAKE_HEADER(BOOL WINAPI SdbStartIndexing(PDB pdb,INDEXID iiWhich))
MAKE_HEADER(BOOL WINAPI SdbStopIndexing(PDB pdb,INDEXID iiWhich))
MAKE_HEADER(TAGID WINAPI SdbBeginWriteListTag(PDB pdb,TAG tTag))
MAKE_HEADER(BOOL WINAPI SdbEndWriteListTag(PDB pdb,TAGID tiList))
MAKE_HEADER(BOOL WINAPI SdbWriteBinaryTag(PDB pdb,TAG tTag,PBYTE pBuffer,DWORD dwSize))
MAKE_HEADER(BOOL WINAPI SdbWriteBinaryTagFromFile(PDB pdb,TAG tTag,LPCWSTR pwszPath))
MAKE_HEADER(BOOL WINAPI SdbWriteStringTag(PDB pdb,TAG tTag,LPCWSTR pwszData))
MAKE_HEADER(BOOL WINAPI SdbWriteDWORDTag(PDB pdb,TAG tTag,DWORD dwData))
MAKE_HEADER(BOOL WINAPI SdbGUIDFromString(LPWSTR str, GUID* guid))
/*
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(*/
#ifdef __cplusplus
}
#endif
#endif

284
util/sdbcreate/sdbcreate.cpp Executable file
View File

@ -0,0 +1,284 @@
/*
* KernelEx
* Copyright(C) 2010, Tihiy, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx 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; version 2 of the License.
*
* KernelEx is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <windows.h>
#include <stdio.h>
#include <shlwapi.h>
#include <map>
#include "sdbapi.h"
#include "wstring.hpp"
using namespace std;
typedef void (*STRPROC) (wchar_t*);
static int sections;
static PDB pdb;
static wchar_t* sdbfile;
static wchar_t inifile[MAX_PATH];
static FILE *regfilei;
static FILE *regfileu;
static map<wstring, TAGID> tagidmap;
void fail()
{
SdbCloseDatabase(pdb);
DeleteFileW(sdbfile);
exit(-1);
}
void WriteTransform(wchar_t* section)
{
//query file name
wchar_t filebuf[MAX_PATH];
wchar_t filepath[MAX_PATH];
wchar_t name[MAX_PATH];
if (!GetPrivateProfileStringW(section, L"Transform", NULL, filebuf, MAX_PATH, inifile))
{
printf("Section %ls does not specify file!\n", section);
fail();
}
//build path to file relative to ini
lstrcpyW(filepath, inifile);
PathRemoveFileSpecW(filepath);
PathAppendW(filepath, filebuf);
wchar_t* filename = PathFindFileNameW(filepath);
lstrcpyW(name, filepath);
PathRemoveExtensionW(name);
PathStripPathW(name);
if (tagidmap.count(name) > 0)
return; //already have it
printf("Adding %ls...", filepath);
//write FILE
TAGID filetagid = SdbBeginWriteListTag(pdb, TAG_FILE);
SdbWriteStringTag(pdb, TAG_NAME, filename);
if (SdbWriteBinaryTagFromFile(pdb, TAG_FILE_BITS, filepath))
printf("Success!\n");
else
{
printf("Failure!\n");
fail();
}
SdbEndWriteListTag(pdb, filetagid);
//write MSI_TRANSFORM
TAGID transfid = SdbBeginWriteListTag(pdb, TAG_MSI_TRANSFORM);
SdbWriteStringTag(pdb, TAG_NAME, name);
SdbWriteStringTag(pdb, TAG_MSI_TRANSFORM_FILE, filename);
SdbWriteDWORDTag(pdb, TAG_MSI_TRANSFORM_TAGID, filetagid);
SdbEndWriteListTag(pdb, transfid);
//add transform tagid to name - tagid map
tagidmap[name] = transfid;
}
void WritePackage(wchar_t* section)
{
//query file name
wchar_t filebuf[MAX_PATH];
wchar_t filepath[MAX_PATH];
wchar_t name[MAX_PATH];
GetPrivateProfileStringW(section, L"Transform", NULL, filebuf, MAX_PATH, inifile);
//build path to file relative to ini
lstrcpyW(filepath, inifile);
PathRemoveFileSpecW(filepath);
PathAppendW(filepath, filebuf);
wchar_t* filename = PathFindFileNameW(filepath);
lstrcpyW(name, filepath);
PathRemoveExtensionW(name);
PathStripPathW(name);
TAGID transfid = tagidmap[name];
//query attributes
wchar_t appname[200];
wchar_t packagecode[100];
GUID guid;
GetPrivateProfileStringW(section, L"AppName", section, appname, 200, inifile);
GetPrivateProfileStringW(section, L"ProductCode", NULL, packagecode, 100, inifile);
if (!SdbGUIDFromString(packagecode, &guid))
{
printf("Section %ls specifies invalid ProductCode!\n", section);
fail();
}
printf("Writing section %ls\n", section);
//write MSI_PACKAGE
TAGID tagid = SdbBeginWriteListTag(pdb, TAG_MSI_PACKAGE);
SdbWriteStringTag(pdb, TAG_NAME, section);
SdbWriteStringTag(pdb, TAG_APP_NAME, appname);
SdbWriteBinaryTag(pdb, TAG_MSI_PACKAGE_ID,(PBYTE) & guid, sizeof(GUID));
//write MSI_TRANSFORM_REF
TAGID reftagid = SdbBeginWriteListTag(pdb, TAG_MSI_TRANSFORM_REF);
SdbWriteStringTag(pdb, TAG_NAME, name);
SdbWriteDWORDTag(pdb, TAG_MSI_TRANSFORM_TAGID, transfid);
SdbEndWriteListTag(pdb, reftagid);
SdbEndWriteListTag(pdb, tagid);
//write registry
if (regfilei)
{
fprintf(regfilei, "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\"
"CurrentVersion\\AppCompatFlags\\Custom\\%ls]\n", packagecode);
fprintf(regfilei, "\"%ls\"=\"%ls\"\n", PathFindFileNameW(sdbfile), appname);
fprintf(regfilei, "\n");
}
if (regfileu)
{
fprintf(regfileu, "[-HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\"
"CurrentVersion\\AppCompatFlags\\Custom\\%ls]\n\n", packagecode);
}
}
void ForEachSection(STRPROC proc)
{
wchar_t sections[0x10000] = { 0 };
wchar_t* strW = sections;
GetPrivateProfileSectionNamesW(strW, 0x10000, inifile);
for(; *strW; strW += lstrlenW(strW) + 1)
proc(strW);
}
void CountSection(wchar_t* section)
{
sections++;
}
void WriteTransforms()
{
TAGID tagid = SdbBeginWriteListTag(pdb, TAG_LIBRARY);
ForEachSection(WriteTransform);
SdbEndWriteListTag(pdb, tagid);
}
void WritePackages()
{
ForEachSection(WritePackage);
}
void WriteDatabase()
{
//count number of sections
sections = 0;
ForEachSection(CountSection);
sections = (sections + 15) & ~15;
//create indexes
INDEXID idx1;
INDEXID idx2;
INDEXID idx3;
SdbDeclareIndex(pdb, TAG_MSI_TRANSFORM, TAG_NAME, sections, TRUE, &idx1);
SdbDeclareIndex(pdb, TAG_MSI_PACKAGE, TAG_MSI_PACKAGE_ID, sections, FALSE, &idx2);
SdbDeclareIndex(pdb, TAG_MSI_PACKAGE, TAG_EXE_ID, sections, TRUE, &idx3);
SdbCommitIndexes(pdb);
//enable indexing
SdbStartIndexing(pdb, idx1);
SdbStartIndexing(pdb, idx2);
SdbStartIndexing(pdb, idx3);
//create database
TAGID tagid = SdbBeginWriteListTag(pdb, TAG_DATABASE);
WriteTransforms();
WritePackages();
SdbEndWriteListTag(pdb, tagid);
//disable indexing
SdbStopIndexing(pdb, idx1);
SdbStopIndexing(pdb, idx2);
SdbStopIndexing(pdb, idx3);
}
int wmain(int argc, wchar_t* argv[])
{
if (argc != 3 && argc != 4)
{
printf("Usage: sdbcreate.exe dbspec.ini out.sdb [out.reg]\n");
return 1;
}
//check ini
GetFullPathNameW(argv[1], MAX_PATH, inifile, NULL);
if (GetFileAttributesW(inifile) == INVALID_FILE_ATTRIBUTES)
{
printf("Failed to open %ls!\n", inifile);
return 2;
}
//create sdb
sdbfile = argv[2];
printf("Creating %ls...\n", sdbfile);
pdb = SdbCreateDatabase(sdbfile, DOS_PATH);
if (!pdb)
{
printf("Failed to create database!\n");
return 3;
}
//create reg
if (argc == 4)
{
wchar_t regpath[MAX_PATH];
lstrcpyW(regpath, argv[3]);
PathRemoveExtensionW(regpath);
lstrcatW(regpath, L".i.reg");
regfilei = _wfopen(regpath, L"w");
fprintf(regfilei, "REGEDIT4\n\n");
lstrcpyW(regpath, argv[3]);
PathRemoveExtensionW(regpath);
lstrcatW(regpath, L".u.reg");
regfileu = _wfopen(regpath, L"w");
fprintf(regfileu, "REGEDIT4\n\n");
}
//write
WriteDatabase();
//close
SdbCloseDatabaseWrite(pdb);
if (regfilei)
fclose(regfilei);
if (regfileu)
fclose(regfilei);
printf("Finished.");
return 0;
}

159
util/sdbcreate/sdbcreate.dsp Executable file
View File

@ -0,0 +1,159 @@
# Microsoft Developer Studio Project File - Name="sdbcreate" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=sdbcreate - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sdbcreate.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sdbcreate.mak" CFG="sdbcreate - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sdbcreate - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "sdbcreate - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sdbcreate - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /W3 /GX /O2 /FI"../../common/msvc_quirks.h" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 shlwapi.lib kernel32.lib shell32.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool
ProjDir=.
TargetPath=.\Release\sdbcreate.exe
SOURCE="$(InputPath)"
PostBuild_Cmds=$(TargetPath) $(ProjDir)\sdbdb\kexsdb.ini $(ProjDir)\sdbdb\KernelEx.sdb $(ProjDir)\sdbdb\kexsdb.reg
# End Special Build Tool
!ELSEIF "$(CFG)" == "sdbcreate - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /FI"../../common/msvc_quirks.h" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 shlwapi.lib kernel32.lib shell32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
ProjDir=.
TargetPath=.\Debug\sdbcreate.exe
SOURCE="$(InputPath)"
PostBuild_Cmds=$(TargetPath) $(ProjDir)\sdbdb\kexsdb.ini $(ProjDir)\sdbdb\KernelEx.sdb $(ProjDir)\sdbdb\kexsdb.reg
# End Special Build Tool
!ENDIF
# Begin Target
# Name "sdbcreate - Win32 Release"
# Name "sdbcreate - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\sdbcreate.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\sdbapi.h
!IF "$(CFG)" == "sdbcreate - Win32 Release"
# PROP Ignore_Default_Tool 1
# Begin Custom Build
OutDir=.\Release
ProjDir=.
InputPath=.\sdbapi.h
"$(OutDir)\sdbapi.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl /nologo /c /TC /DSDBAPI_IMPLIB /Fo$(OutDir)\sdbapi.obj "$(ProjDir)\sdbapi.h"
link /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 /DEF:"$(ProjDir)\sdbapi.def" /OUT:$(OutDir)\sdbapi.dll /IMPLIB:$(OutDir)\sdbapi.lib $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.exp
del $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.dll
# End Custom Build
!ELSEIF "$(CFG)" == "sdbcreate - Win32 Debug"
# PROP Ignore_Default_Tool 1
# Begin Custom Build
OutDir=.\Debug
ProjDir=.
InputPath=.\sdbapi.h
"$(OutDir)\sdbapi.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl /nologo /c /TC /DSDBAPI_IMPLIB /Fo$(OutDir)\sdbapi.obj "$(ProjDir)\sdbapi.h"
link /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 /DEF:"$(ProjDir)\sdbapi.def" /OUT:$(OutDir)\sdbapi.dll /IMPLIB:$(OutDir)\sdbapi.lib $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.exp
del $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.dll
# End Custom Build
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\wstring.hpp
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

BIN
util/sdbcreate/sdbdb/gearth.mst Executable file

Binary file not shown.

39
util/sdbcreate/sdbdb/kexsdb.ini Executable file
View File

@ -0,0 +1,39 @@
[office2007conv]
AppName=Office 2007 File Format Converters
ProductCode={90120000-0020-0409-0000-0000000FF1CE}
Transform=o12conv.mst
[wordview2003]
AppName=Word Viewer 2003
ProductCode={90850409-6000-11D3-8CFE-0150048383C9}
Transform=office2003.mst
[xlview2003]
AppName=Excel Viewer 2003
ProductCode={90840409-6000-11D3-8CFE-0150048383C9}
Transform=office2003.mst
[office2003pro]
AppName=Office 2003 Professional
ProductCode={90110409-6000-11D3-8CFE-0150048383C9}
Transform=office2003.mst
[gearth51]
AppName=Google Earth 5.1
ProductCode={B59EF430-4849-11DF-B1EC-005056806466}
Transform=gearth.mst
[gearth52]
AppName=Google Earth 5.2
ProductCode={2EAF7E61-068E-11DF-953C-005056806466}
Transform=gearth.mst
[gearth6]
AppName=Google Earth 6 beta
ProductCode={6DB7AD00-F781-11DF-9EEF-001279CD8240}
Transform=gearth.mst
[acroread7]
AppName=Acrobat Reader 7
ProductCode={AC76BA86-7AD7-1033-7B44-A70900000002}
Transform=reader7.mst

BIN
util/sdbcreate/sdbdb/o12conv.mst Executable file

Binary file not shown.

Binary file not shown.

BIN
util/sdbcreate/sdbdb/reader7.mst Executable file

Binary file not shown.

89
util/sdbcreate/wstring.hpp Executable file
View File

@ -0,0 +1,89 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
* Copyright (C) 2010, Tihiy
*
* This file is part of KernelEx source code.
*
* KernelEx 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; version 2 of the License.
*
* KernelEx is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __WSTRING_HPP
#define __WSTRING_HPP
#include <string.h>
/** Simple string container class. */
class wstring
{
public:
wstring(const WCHAR* src)
{
len = lstrlenW(src);
storage = new WCHAR[len + 1];
lstrcpyW(storage, src);
}
wstring(const wstring& src)
{
len = src.len;
storage = new WCHAR[len + 1];
lstrcpyW(storage, src.storage);
}
~wstring()
{
delete [] storage;
}
wstring& operator=(const wstring& src)
{
len = src.len;
delete [] storage;
storage = new WCHAR[len + 1];
lstrcpyW(storage, src.storage);
return *this;
}
wstring& operator=(const WCHAR* src)
{
len = lstrlenW(src);
delete [] storage;
storage = new WCHAR[len + 1];
lstrcpyW(storage, src);
return *this;
}
bool operator<(const wstring& a) const
{
return lstrcmpiW(storage, a.storage) < 0;
}
operator const WCHAR*() const
{
return storage;
}
int length() const
{
return len;
}
private:
int len;
WCHAR* storage;
};
#endif