This is archived copy of currently unavailable Nem's Tools website, restored from Web Archive.
Download section now provides links to both Web Archive and to this unofficial Github mirror.
HLLib - NemPosted: May 23rd, 2005 - 6:32:20 pm
About:

HLLib is a package library for Half-Life that abstracts several package formats and provides a simple interface for all of them. HLLib is written in native C++ but exposes both a C and C++ interface which can be used in any C or C++ application (additional languages may also use the library with standard C imports). HLLib works natively in both Windows (x86 and x64) and Linux. BSP, GCF, NCF, PAK, VPK, WAD, XZP and uncompressed ZIP package formats are supported.

HLLib is an open source library licensed under the LGPL. It comes with the source code and binaries necessary to use it. An example application called HLExtract, which is licensed under the GPL, is also included. HLExtract is a command line utility written in C that can load all HLLib supported packages and extract multiple items from them while maintaining their directory structure. Also included is a C# HLExtract port called HLExtract.Net.

Download from Web Archive: Download from unofficial Github mirror: GridMount:

A MacFUSE file system handler called GridMount is available for those looking to run HLLib on a Mac.

Java Wrapper:

A Java wrapper is available for those looking to use HLLib in Java. It can be found on SourceForge.

Revision History:

v2.4.6
  • Modified VPF file support to handle the removal of a null terminator from the end of the directory.
v2.4.5
  • Added support for new SGA file format (v6).
  • Added support for new SGA file format (v7).
v2.4.4
  • Fixed support for VPK file format (v1).
v2.4.3
  • Added support for new VPK file format (v2).
  • Added SGA file support.
  • Added ZIP deflate support.
v2.4.2
  • Fixed crash when opening VBSP files with no pak file lump.
v2.4.1
  • Fixed crash in CProcStream.
  • Fixed VPK signature check.
  • Workaround for crash in .Net wrapper.
v2.4.0
  • Added support for GCF files larger than 4 GB.
v2.3.0
  • Added support for x64.
  • Added Visual Studio 2010 solution.
  • Added Visual Studio 2008 solution..
  • Removed Visual Studio 2003 solution.
v2.2.0
  • Added support for packages larger than 4 GB.
v2.1.2
  • Added support for new VBSP file format.
v2.1.1
  • Added support for new VPK file format.
  • Added VPK file validation.
  • Fixed crash when closing VPK files.
v2.1.0
  • Added VPK file support.
v2.0.11
  • Added VBSP .lmp support.
  • Fixed support for files over 2 GB.
v2.0.10
  • Added Last Version Played attribute to NCF file.
  • Fixed change to directory entry folder terminator.
v2.0.9
  • Added Last Version Played attribute to GCF file.
v2.0.8
  • Improved GCF version check.
  • Fixed fragmentation header checksum after defragment.
v2.0.7
  • Added different search string comparisons.
  • Added Visual Studio 2005 solution.
  • Improved package type tests.
v2.0.6
  • Added generic write support to mapping interface.
  • Added no recurse option to FindFirst()/FindNext().
  • Improved package item attribute consistency.
  • Fixed GCC visibility support.
  • Fixed unnecessary GCF bounds check.
  • Fixed BSP unused lump check.
v2.0.5
  • Added Linux support.
  • Fixed near infinite find next recursion.
v2.0.4
  • Fixed bug in GCF file defragmentation progress.
v2.0.3
  • Added NCF file support.
v2.0.2
  • Added GCF file defragmentation.
  • Added fragmentation property to GCF files.
  • Added Dark Messiah VBSP support.
  • Fixed hlPackageCreateStream() bug.
  • Fixed CMapping::GetTotalMemoryUsed() calculation.
  • Fixed PAK file path parsing.
  • Improved error messages.
  • Improved file mapping performance.
v2.0.1
  • Added memory tracking.
  • Improved view management.
  • Fixed memory mapping bug.
  • Fixed user data bug in proc reader.
  • Fixed WAD file GetImageData() bug.
  • Fixed default mapping stream view size.
  • Fixed a minor memory leak.
v2.0.0
  • Rewrote entire library.
  • Open packages from anywhere (files, memory, abstract streams).
  • Get package and item attributes.
  • Stream package data.
  • Validate package data.
  • Added a C wrapper.
  • Improved and optimized package loading code.
  • Improved package detection.
v1.1.8
  • Added XZP file support.
v1.1.7
  • Added Source engine BSP support.
v1.1.6
  • Added mipmap level option to CWADFile.
v1.1.5
  • Improved WAD file support.
v1.1.4
  • Improved detection of corrupt packages.
v1.1.3
  • Extended CGCFFile.
  • Extended CFileMapping and CPrimitiveFileMapping to allow for volatile access.
  • Fixed CPackageUtility::Extract() bug caused by illegal characters.
  • Files of size 0 B are now treated as valid files.
v1.1.2
  • Extended CPackage.
  • Extended CMappedPackage.
  • Improved error messages for system calls.
v1.1.1
  • Fixed last error not being set in CMappedPackage::Open().
v1.1.0
  • Rewrote mapping code to be more flexible.
  • Packages located on disk or in memory can now be loaded.
  • Optimized file mapping.
  • Fixed CPackage::Root bug.
  • Fixed CGCFFile::GetFileSizeOnDisk() bug.
v1.0.4
  • Fixed CPackage memory leak.
  • Fixed CMappedPackage initialization bug.
  • Fixed CMappedPackage deinitialization bug.
  • Changed CDirectoryItem::Parent to a CDirectoryFolder.
  • Extended CWADFile.
  • Added CBSPFile which acts like CWADFile on a BSP's textures.
v1.0.3
  • Extended CWADFile.
  • Changed GetFileSizeEx() to GetFileSize() (Not all versions of Windows supported the former).
v1.0.2
  • Extended CPackage.
  • Extended CGCFFile.
  • Converted from bool to BOOL.
  • HLLib now used by GCFScape.
v1.0.1
  • Added callback functionality to CPackageUtility::Extract().
  • Extended CGCFFile.
  • Minor bug fixes.
v1.0.0
  • Original build.
Modified: Jan 22nd, 2017 - 6:09:30 pm[ 72146 Views ]

1. Da_FileServerPosted: Sep 5th, 2004 - 12:05:16 am

Well, this looks like a pretty spiffy library... but you should create dsw and dsp files for people who are jacked with VC++6. But I'm not one of them (I have neither--I compile them all by hand using .NET toolkit and lots of microsoft SDK's happy).

2. NemPosted: Sep 5th, 2004 - 8:37:03 am

If I had Visual Studio 6.0 I would have but I don't. That said, there is no reason to need to compile the library (as the binaries are included) unless you want to make changes to it and if a Visual Studio 6.0 user does want to make changes, it is not to hard for them to convert (or recreate) the project files.

Visual Studio 6.0 users might also be interested in the free build of Visual C++ .NET 2005 Express Beta from Microsoft.

3. VarsityPosted: Dec 31st, 2005 - 2:37:21 pm
Will I be able to use HLLib in a C# Express project?

4. NemPosted: Dec 31st, 2005 - 3:26:48 pm
If you wrote a C++ .NET wrapper.

5. VarsityPosted: Jan 4th, 2006 - 10:09:02 am
.NET allows different languages to coexsist in the same project, or something along those lines. Wouldn't simply compiling HLLib into C++ .NET do the trick?

6. the-copyPosted: Jan 4th, 2006 - 11:44:09 am
What is a C++ .NET wrapper and how can i do it? apple

7. NemModified: Jan 4th, 2006 - 3:04:05 pm
C++ .NET is an extension of C++ and is managed in the same way that C# and VB code is managed. However, C++ .NET still allows for native C++ code. If you want to use native C++ in a .NET language other than C++ .NET you need to write a managed class that has the same structure as its equivalent unmanaged class that performs the necessary conversions, eg:

Code:

// Original class
class CExample
{
public:
CExample()
{
string = 0;
}

~CExample()
{
delete []string;
}

char *GetString()
{
return string;
}

void SetString(const char *newString)
{
delete []string;
string = new char[strlen(newString) + 1];
strcpy(string, newString);
}

private:
char *string;
};

using namespace System::Runtime::InteropServices;

// Wrapper class
__gc class Example
{
public:
System::String *GetString()
{
return new System::String(example.GetString());
}

void SetString(System::String *newString)
{
char *string = (char *)(Marshal::StringToHGlobalAnsi(newString)).ToPointer();
example.SetString(string);
Marshal::FreeHGlobal((System::IntPtr)string);
}

private:
CExample example;
};

However, I will be completing HLLib 2.0 soon which will have a C wrapper which you should be able to directly import into any C# project (in fact almost any project in any language).

8. the-copyPosted: Jan 5th, 2006 - 6:31:48 am
Nem:
However, I will be completing HLLib 2.0 soon which will have a C wrapper which you should be able to directly import into any C# project (in fact almost any project in any language).

Oh thats great :D

9. ultradude25Modified: Sep 16th, 2009 - 11:03:22 am
When I use HLExtract to defrag my GCF's I get this error on one of them:



Is there anything I can do to fix this?

Oh and all the other GCF's defragged fine.

10. etamPosted: Sep 29th, 2009 - 10:11:50 am
Open Source FTW!
I created rpm packages for openSuSE 11.1 (and 11.0)

here are repos: http://download.opensuse.org/repositories/home:/etamPL/

I separated this in 3 packages: libhl2, libhl2-devel, HLExtract

11. szwipModified: Oct 15th, 2009 - 7:43:05 am
Hi

I try to use HLLib with MinGW compiler, but I have this error:
C:\...\HLLib.h|740|error: 'HANDLE' does not name a type

Where is normally defined HANDLE ?

EDIT 1: I have added this lines at the begin of HLLib.h, and now HANDLE is ok:
#ifdef _WIN32
# include <windows.h>
#endif


EDIT 2: Now I've several error with linker such as:
undefined reference to `HLLib::CPackage::GetRoot()'

The linker finds HLLib.lib, but the c++ function are unknown (I use directly the c++ class and functions)

EDIT 3: A solution, but it's ugly, it's to include all files from source in my project. It compiles and links correctly :)
============================================

Another problem : in the main.c of HLExtract, it's hl.h that is included (line 20), but it doesn't exist. What is hl.h ?

Thank.

12. NemPosted: Oct 16th, 2009 - 12:35:53 am
You need to include ..\lib\HLLib.h not <hl.h> in Main.c; the latter is for the Linux environment. The top should probably read:

Code:
#ifdef _WIN32
# include "..\lib\HLLib.h"
# ifdef _MSC_VER
# pragma comment(lib, "../../../lib/HLLib.lib")
# endif
#else
# include <hl.h>
#endif

Including Windows.h before HLLib.h should work fine without modifying any HLLib files.

If you aren't using Visual Studio, you should build your own .lib and .dll.

13. FunsizePosted: Dec 22nd, 2009 - 6:19:50 am
Just noticed that the link HLLib v2.2.0 Archive (338 KB) links to the non-existent file http://nemesis.thewavelength.net/files/files/hllib212.zip rather than http://nemesis.thewavelength.net/files/files/hllib220.zip which is what it should be.

14. NemPosted: Dec 28th, 2009 - 11:37:12 am
Thanks, fixed. free

15. MadJawaPosted: Dec 29th, 2009 - 3:12:02 pm
Hey, I just downloaded the sources and tried to compile them on Linux, and I got errors about functions like "strlen", etc. I had to include <string.h> in 2 or 3 files in HLLib to be able to compile it.

16. jwheareModified: Jun 13th, 2010 - 4:03:07 pm
I turned this into a homebrew package for Mac OS X

http://github.com/mxcl/homebrew/blob/master/Library/Formula/hllib.rb

It only required a few minor tweaks to the Makefile and HLExtract source, mainly to replace the .so extensions with .dylib and fixing the limits.h include. Would be good if these changes could make it back to your package via some IFDEFS.

Cheers, hlextract is a great tool.

17. NemPosted: Jun 14th, 2010 - 1:42:26 am
Do you have a diff for your code changes? I'd be happy to integrate them in.

18. Crowley22gModified: Jun 14th, 2010 - 4:10:32 am
Great tools been using for years love

Wrote a script a while back to extract all the required files to build a Synergy Server :-)

This worked great until Valve did the updates for Apple Mac

Now Hlextract will not extract the NEW updated files some of which are maps :-(

d1_eli_01.bsp
d1_town_05.bsp
d2_coast_01.bsp

Thats only a few from Half-life 2

Hope it's something simple. I'm sure there are other Synergy server admins saying OMG what have they done LOL

Thanks in advance

Crowley

PS file will extract using GCFScape 1.8.0 (On Win 7 x64)
The server is Win2003 R2

19. Crowley22gPosted: Jun 20th, 2010 - 5:52:35 am
Done a bit more digging.

d1_eli_01.bsp is grey and will not extract on Server 2003 R2

d1_eli_01.bsp is fine and will extract OK on my Win 7 x64 PC

Also tried the HLExtract and the .net version on 2003 R2 and they get the same error message about the file not being complete

Hope you can help. If not I'll have to upload all the files from my Win 7 PC

Cheers

Crowley

20. neicoModified: Jul 25th, 2010 - 3:28:33 pm
could you consider to include the .pdb files for the HLLib.dll and the hlextract.exe in the next release? it would help people that don't build them and just use what comes with the download ;)

and to the thing about the new bsp files etc. I think I've come across the same problem, I guess the lib needs a little update for those... (using the Lib together with wxWidgets to write an GUI based extractor for just extracting content that doesn't come with hldsupdatetool but is required for mods like Synergy or Obsidian Conflict)

It also seems that CDirectoryFolder->FindFirst and FindNext don't work as they should when using only HL_FIND_FOLDER, it doesn't search all folders, only those inside that folder, it only works if I also add the flag HL_FIND_FILES

21. Crowley22gPosted: Jul 26th, 2010 - 5:41:07 pm
The files extracted on Win7 x64 when placed on the Synergy server still give a message "Server version differs". Whatever they did in the Mac update has broken some but not all files from being extracted correctly.

For the time being i've had to remove 15 maps from the mapcycle to prevent getting an empty server because no one can join.

Thanks in advance

22. Crowley22gPosted: Aug 7th, 2010 - 5:36:09 pm
Problem solved thanks to a reply on GCFScape

Missing file with the NEW updated maps etc... are now located in :

half-life 2 2007 base content.gcf

Now loaded on our server an working again :-)

23. ArimanPosted: May 2nd, 2011 - 5:34:18 am
Hi. I've encountered a small issues with HLLib.
In lpPackageTests array (which is used for hlGetPackageTypeFromMemory function) signature for VPK files defined as { 0x34, 0x12, 0x55, 0xaa }, but in Portal 2 pak01_dir.vpk has signature { 0x34, 0x12, 0xaa, 0x55 }.
And it can be opened with no problems. Is it an error in signature definition or both versions are valid?

24. NemPosted: May 2nd, 2011 - 10:39:52 pm
Good catch, the signature check should be against { 0x34, 0x12, 0xaa, 0x55 }.

apple

25. ArimanPosted: May 3rd, 2011 - 4:03:12 am
Got it. Thanks.

26. NemPosted: May 11th, 2011 - 1:45:59 am
Version 2.4.1 has been released with a fixed signature check and a few other minor fixes.

27. King2500Posted: May 12th, 2011 - 6:40:00 pm
Hello Nem,

With Version 2.4.1 of HLLib I have the problem that I get a crash when mounting a AlienSwarm or Portal 2 BSP and calling GetRoot()

Same problem (similar error) applies to GCFScape in latest version.

28. neicoModified: Aug 5th, 2011 - 3:03:31 am
Just wanted to say that it would a good thing to add GetExtractable() to the Extract function since it's pretty obvious that the lib shouldn't try to extract if it's not extractable...

Also, could you provide a way to give out only the file / folder count that's been downloaded (and in fact is extractable), a simple GetFileCount( hlBool OnlyCompleted = false ) should be enough I guess~
else I really would need to add some extra looping just to archive that :S

I've also got an report from an tester that when I use Extract on an entire folder that it extracts files which show up in GCFScape as gray ( not downloaded ) too, but those are then 0 byte big, maybe this is related to the extract function not checking if it's extractable D:

I've also noticed that the Callbacks are only available in C Code, so I can't really use them to call Class Members (hlSetVoid would need an extra parameter to allow passing this for static functions at least~).
So making C Code features ( like the Callbacks ) usable with C++ Code would be cool :D

I would suggest making a class HLLib that has members like: RegisterCallback( hlOption Callback, hlCallback, hlVoid* EventHandler );
and the same for Unregister and stuff like that, you know what I mean~

29. kevincoxPosted: Jan 30th, 2013 - 3:21:19 am
Hi. I am trying to build these packages on linux (I'm actually trying to get them into the AUR (Arch User Repository) but I am running into problems building HLExtract.

HLLib appears to build and install fine using the Makefile but when I try to compile HLExtract using the following command I get the following error.

cc -o 'hlextract' -I "$headerdir" -L "$libdir" 'Main.c' -lhl
/data/Desktop/dassault-systemes-draftsight/pkg/usr/lib//libhl.so: undefined reference to `HLLib::CSGAFile::CSGAFile()'
collect2: error: ld returned 1 exit status

I might be doing something silly and would appreciate any help.

30. NemPosted: Jan 31st, 2013 - 6:01:30 am
Don't really maintain the Linux support, but it shouldn't be hard to get going again.

Add SGAFile.cpp to the makefile?

If you get it working send me your changes and I'll make sure they get in to the next release.

31. kevincoxModified: Feb 14th, 2013 - 10:05:20 pm
Thanks, all that was missing was that file. I'm not too familiar with make but there is a way to pattern match all of your source files so you don't forget to add any in the future.

Here are my results:
- Here is my final Makefile (just added that file) http://pastebin.com/bFQcbMaj
- Here is a patch for the Makefile http://pastebin.com/Fb6RAzzs
- Here is the AUR package, it's PKGBUILD is essentially a shell script that can be used as a reference on how to build it. https://aur.archlinux.org/packages/hllib/

Thanks again for the help. HLExtract worked perfectly.

32. sl1pkn07Posted: Feb 14th, 2013 - 11:32:35 pm
ive upload hllib(named hlextract) in AUR [1] since 2010, i use the patchset from OpenSuse Game repository [2](before from etamPL repository [3])

the patchet:

http://paste.ubuntu.com/1654243
http://paste.ubuntu.com/1654244
http://paste.ubuntu.com/1654245

and little fix to change Win to unix EOL (end of line) to apply the patchset

find -type f -exec perl -pi -e 's/\r\n?/\n/g' "{}" \;

only have a little trouble with certain warning

http://paste.ubuntu.com/1654270

(sorry, im not coder)

greetings

[1] https://aur.archlinux.org/packages/hlextract/
[2] http://download.opensuse.org/repositories/games/openSUSE_12.2/src/libhl2-2.4.3-1.1.src.rpm
[3] http://nemesis.thewavelength.net/index.php?c=108&o=0#c3261

33. sl1pkn07Posted: Nov 4th, 2013 - 12:48:50 am
hi

Nem, can you update the linux makefililes?

missing SGAFile.cpp into hllib/Makefile

but with add the make fail:

http://sl1pkn07.no-ip.com/paste/view/b620763b

and still have this warnings:

http://sl1pkn07.no-ip.com/paste/view/456cd2af

greetings

34. NemPosted: Nov 6th, 2013 - 5:40:12 am
Try going to SGAfile.h and adding typename to the template parameter typedefs. E.g.:

Change:
typedef TSGAHeader SGAHeader;
To:
typedef typename TSGAHeader SGAHeader;

Except for the SGAFile typedefs that don't use a template parameter.

35. sl1pkn07Posted: Nov 9th, 2013 - 11:21:36 pm
Hi

what change need exactly? im not coder :S

greetings

36. Ravu al HemioPosted: Nov 22nd, 2013 - 1:09:46 am
Hi,

I have a HLLib version that successfully compiles under Linux on Github. I try to keep it in sync with HLLib releases. (If I miss a release, open an issue there!)

Cheers.

37. sl1pkn07Posted: Nov 27th, 2013 - 10:30:12 pm
@Ravu al Hemio

THANKS!!!

greetings

38. sl1pkn07Posted: Sep 28th, 2014 - 3:42:54 pm
Hi. you change any in the zip?

stop build with the @Ravu al Hemio patchset for linux

greetings

39. tgnottinghamModified: Sep 21st, 2015 - 8:59:40 am
I've created a Python binding for HLLib, available at https://github.com/tgnottingham/hllib.py.

Features:
- The Python binding as a module, hllib.py.
- A Python version of HLExtract, hlextract.py.
- A modest amount of documentation.
- Works under Linux and Windows.

Nem's Tools v2.0 © 2006 Ryan Gregg.
Execution time: 0.07963s; Queries: 14.