BazisLib Main Page
Overview
Welcome to the BazisLib homepage. BazisLib is a library that
simplifies development of drivers and applications for Windows x86/x64 and
Windows Mobile. It consists of an object-oriented framework for creating Windows
drivers (including a patched version of STLPort), a set of common interfaces for
kernel- and user-mode services, and a set of classes for simplifying several
user-mode Windows tasks, such as dealing with files or managing Windows
Services. Many open-source projects provided by SysProgs, such as
WinCDEmu, are based on BazisLib.
Documentation
You can find detailed reference for all BazisLib classes
here.
Installation
Starting from version 2.2.0, BazisLib includes a convenient
installer, that detects, installs and configures all prerequisites
automatically. You can download the installer from the
SourceForge project page.
License and commercial use
BazisLib is available under LGPL license. To get a commercial license without
LGPL restrictions contact sales@sysprogs.com.
More information is available here.
Example
Here is a simple example of a PnP ramdisk driver for Windows written
with BazisLib. A task that usually takes kilobytes of code, is solved in a
simple and lightweight way, leaving all the routine work to the BazisLib
framework:
#include <bzsddk/bzsddk.h>
#include <bzsddk/crossplatform/crossvol.h>
#define RAMDISK_SECTOR_SIZE 512
namespace BazisLib
{
class RamDisk :
public IBasicDisk
{
protected:
ULONGLONG m_SectorCount;
ULONGLONG m_TotalSize;
char *m_pBuffer;
public:
unsigned GetSectorSize() {return
RAMDISK_SECTOR_SIZE;}
void Dispose();
RamDisk(unsigned MegabyteCount)
{
m_SectorCount
= MegabyteCount * (1024 * 1024 / RAMDISK_SECTOR_SIZE);
m_TotalSize =
MegabyteCount * 1024 * 1024;
m_pBuffer =
(char *)bulk_malloc((unsigned)m_TotalSize);
}
~RamDisk()
{
if (m_pBuffer)
bulk_free(m_pBuffer, m_TotalSize);
}
virtual ULONGLONG GetSectorCount()
override {return m_SectorCount; }
virtual unsigned Read(ULONGLONG
ByteOffset, void *pBuffer, unsigned Length) override
{
if (!m_pBuffer)
return 0;
LONGLONG
MaxSize = m_TotalSize - ByteOffset;
if (MaxSize <
0)
MaxSize = 0;
if (Length >
MaxSize)
Length = MaxSize;
memcpy(pBuffer, m_pBuffer + ByteOffset, Length);
return
Length;
}
virtual unsigned Write(ULONGLONG
ByteOffset, const void *pBuffer, unsigned Length) override
{
if (!m_pBuffer)
return 0;
LONGLONG
MaxSize = m_TotalSize - ByteOffset;
if (MaxSize <
0)
MaxSize = 0;
if (Length >
MaxSize)
Length = MaxSize;
memcpy(m_pBuffer + ByteOffset, pBuffer, Length);
return
Length;
}
virtual LPGUID GetStableGuid()
override {return NULL;}
virtual bool DeviceControl(unsigned CtlCode, void *pBuffer, unsigned InSize,
unsigned OutSize, unsigned *pBytesDone)
override
{
return false;
}
virtual bool Initialize() override {return
true;}
};
using namespace DDK;
class RamDiskDriver : public Driver
{
public:
RamDiskDriver() : DDK::Driver(true)
{
}
virtual NTSTATUS AddDevice(IN
PDEVICE_OBJECT PhysicalDeviceObject) override
{
UniversalVolume *pVol = new UniversalVolume(new RamDisk(256), true);
if (!pVol)
return STATUS_NO_MEMORY;
NTSTATUS st =
pVol->AddDevice(this, PhysicalDeviceObject);
if (!NT_SUCCESS(st))
return st;
return
STATUS_SUCCESS;
}
virtual ~RamDiskDriver()
{
}
};
DDK::Driver *_stdcall CreateMainDriverInstance()
{
return new RamDiskDriver();
}
}
Detailed description of BazisLib and detailed class reference
can be found here.
Support
Feel free to ask questions regarding BazisLib on the
SysProgs.org forum.