Skip to content

Instantly share code, notes, and snippets.

@SwooshyCueb
Created December 5, 2019 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SwooshyCueb/66a06752972748ca84ff219cdd58ca00 to your computer and use it in GitHub Desktop.
Save SwooshyCueb/66a06752972748ca84ff219cdd58ca00 to your computer and use it in GitHub Desktop.
quick and dirty delta package extractor using dpx.dll
#define UNICODE 1
#include <windows.h>
#include <stdio.h>
#include <shellapi.h>
#include <dpx.h>
#include <malloc.h>
using namespace std;
void print_usage(LPWSTR exename) {
wprintf(L"usage:\n");
wprintf(L"%s package [destination]\n", exename);
}
int __cdecl main()
{
LPWSTR *argv;
int argc;
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if ((argv == NULL) || (argc < 1)) {
wprintf(L"internal error\n");
return -1;
} else if (argc == 1) {
print_usage(argv[0]);
return -1;
}
LPWSTR cabPathAsPassed = argv[1];
DWORD cabPathLen = GetFullPathNameW(cabPathAsPassed, 0, NULL, NULL);
LPWSTR cabPath = static_cast<LPWSTR>(_malloca(cabPathLen * sizeof(WCHAR)));
GetFullPathNameW(cabPathAsPassed, cabPathLen, cabPath, NULL);
DWORD exPathLen;
LPWSTR exPath;
if (argc > 2) {
LPWSTR exPathAsPassed = argv[2];
exPathLen = GetFullPathNameW(exPathAsPassed, 0, NULL, NULL);
exPath = static_cast<LPWSTR>(_malloca(exPathLen * sizeof(WCHAR)));
GetFullPathNameW(exPathAsPassed, exPathLen, exPath, NULL);
} else {
exPathLen = GetCurrentDirectoryW(0, NULL);
exPath = static_cast<LPWSTR>(_malloca(exPathLen * sizeof(WCHAR)));
GetCurrentDirectoryW(exPathLen, exPath);
}
wprintf(L"Extracting %s\n", cabPath);
wprintf(L" to %s\n", exPath);
IDpxJob *dpxJob = NULL;
DpxNewJob(exPath, &dpxJob);
IDpxContainer *cab = NULL;
dpxJob->AddContainer(cabPath, &cab);
cab->ExtractAllFiles();
dpxJob->Resume(DPX_RESUME_AND_DOWNLOAD);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment