Fixed line endings and applied gitignore

This commit is contained in:
2014-07-26 09:43:40 +03:00
parent 0c57cabe56
commit 7cba5cc109
542 changed files with 112014 additions and 119759 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,132 +1,132 @@
/*
Copyright (C) 2012 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SKININSTALLER_DIALOGINSTALL_H_
#define SKININSTALLER_DIALOGINSTALL_H_
#include <string>
#include "unzip.h"
#include "../Library/Dialog.h"
class DialogInstall : public Dialog
{
public:
static void Create(HINSTANCE hInstance, LPWSTR lpCmdLine);
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnInitDialog(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
static DialogInstall* c_Dialog;
protected:
virtual Tab& GetActiveTab();
private:
friend class DialogPackage;
class TabInstall : public Tab
{
public:
TabInstall(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};
enum Timer
{
Thread = 1
};
enum PackageFormat
{
None,
New,
Old
};
enum PackageFlag
{
Backup = 0x0001
};
struct PackageFooter
{
__int64 size;
BYTE flags;
char key[7];
};
DialogInstall(HWND wnd, const WCHAR* file);
virtual ~DialogInstall();
bool ReadPackage();
bool ReadOptions(const WCHAR* file);
bool InstallPackage();
void BeginInstall();
static UINT __stdcall InstallThread(void* pParam);
bool ExtractCurrentFile(const std::wstring& fileName);
void LaunchRainmeter();
void KeepVariables();
static void CleanLayoutFile(const WCHAR* file);
static bool IsIgnoredSkin(const WCHAR* name);
static bool IsIgnoredLayout(const WCHAR* name);
static bool IsIgnoredAddon(const WCHAR* name);
static bool IsIgnoredPlugin(const WCHAR* name);
static int CompareVersions(const std::wstring& strA, const std::wstring& strB);
static std::vector<std::wstring> Tokenize(const std::wstring& str, const std::wstring& delimiters);
static bool CreateDirectoryRecursive(const std::wstring& path);
static std::wstring GetFileVersionString(const WCHAR* fileName);
static std::wstring GetDotNetVersionString();
static std::wstring GetWindowsVersionString();
TabInstall m_TabInstall;
HBITMAP m_HeaderBitmap;
HANDLE m_InstallThread;
std::wstring m_ErrorMessage;
unzFile m_PackageUnzFile;
std::wstring m_PackageFileName;
std::wstring m_PackageRoot;
PackageFormat m_PackageFormat;
std::set<std::wstring> m_PackageSkins;
std::set<std::wstring> m_PackageLayouts;
std::set<std::wstring> m_PackageAddons;
std::set<std::wstring> m_PackageFonts;
std::set<std::wstring> m_PackagePlugins;
bool m_BackupPackage;
bool m_BackupSkins;
bool m_MergeSkins;
bool m_SystemFonts;
std::vector<std::wstring> m_VariablesFiles;
std::vector<std::wstring> m_LoadSkins;
std::wstring m_LoadLayout;
};
#endif
/*
Copyright (C) 2012 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SKININSTALLER_DIALOGINSTALL_H_
#define SKININSTALLER_DIALOGINSTALL_H_
#include <string>
#include "unzip.h"
#include "../Library/Dialog.h"
class DialogInstall : public Dialog
{
public:
static void Create(HINSTANCE hInstance, LPWSTR lpCmdLine);
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnInitDialog(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
static DialogInstall* c_Dialog;
protected:
virtual Tab& GetActiveTab();
private:
friend class DialogPackage;
class TabInstall : public Tab
{
public:
TabInstall(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};
enum Timer
{
Thread = 1
};
enum PackageFormat
{
None,
New,
Old
};
enum PackageFlag
{
Backup = 0x0001
};
struct PackageFooter
{
__int64 size;
BYTE flags;
char key[7];
};
DialogInstall(HWND wnd, const WCHAR* file);
virtual ~DialogInstall();
bool ReadPackage();
bool ReadOptions(const WCHAR* file);
bool InstallPackage();
void BeginInstall();
static UINT __stdcall InstallThread(void* pParam);
bool ExtractCurrentFile(const std::wstring& fileName);
void LaunchRainmeter();
void KeepVariables();
static void CleanLayoutFile(const WCHAR* file);
static bool IsIgnoredSkin(const WCHAR* name);
static bool IsIgnoredLayout(const WCHAR* name);
static bool IsIgnoredAddon(const WCHAR* name);
static bool IsIgnoredPlugin(const WCHAR* name);
static int CompareVersions(const std::wstring& strA, const std::wstring& strB);
static std::vector<std::wstring> Tokenize(const std::wstring& str, const std::wstring& delimiters);
static bool CreateDirectoryRecursive(const std::wstring& path);
static std::wstring GetFileVersionString(const WCHAR* fileName);
static std::wstring GetDotNetVersionString();
static std::wstring GetWindowsVersionString();
TabInstall m_TabInstall;
HBITMAP m_HeaderBitmap;
HANDLE m_InstallThread;
std::wstring m_ErrorMessage;
unzFile m_PackageUnzFile;
std::wstring m_PackageFileName;
std::wstring m_PackageRoot;
PackageFormat m_PackageFormat;
std::set<std::wstring> m_PackageSkins;
std::set<std::wstring> m_PackageLayouts;
std::set<std::wstring> m_PackageAddons;
std::set<std::wstring> m_PackageFonts;
std::set<std::wstring> m_PackagePlugins;
bool m_BackupPackage;
bool m_BackupSkins;
bool m_MergeSkins;
bool m_SystemFonts;
std::vector<std::wstring> m_VariablesFiles;
std::vector<std::wstring> m_LoadSkins;
std::wstring m_LoadLayout;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,127 +1,127 @@
/*
Copyright (C) 2012 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SKININSTALLER_DIALOGPACKAGE_H_
#define SKININSTALLER_DIALOGPACKAGE_H_
#include <string>
#include "zip.h"
#include "../Library/Dialog.h"
class DialogPackage : public Dialog
{
public:
static void Create(HINSTANCE hInstance, LPWSTR lpCmdLine);
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnInitDialog(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
static DialogPackage* c_Dialog;
protected:
virtual Tab& GetActiveTab();
private:
class TabInfo : public Tab
{
public:
TabInfo(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
};
class TabOptions : public Tab
{
public:
TabOptions(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
};
class TabAdvanced : public Tab
{
public:
TabAdvanced(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
};
DialogPackage(HWND wnd);
virtual ~DialogPackage();
void SetNextButtonState();
bool CreatePackage();
static unsigned __stdcall PackagerThreadProc(void* pParam);
bool AddFileToPackage(const WCHAR* realPath, const WCHAR* zipPath);
bool AddFolderToPackage(const std::wstring& path, std::wstring base, const WCHAR* zipPrefix);
void ShowHelp();
static std::wstring SelectFolder(HWND parent, const std::wstring& existingPath);
static INT_PTR CALLBACK SelectFolderDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static std::pair<std::wstring, std::wstring> SelectPlugin(HWND parent);
static INT_PTR CALLBACK SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
TabInfo m_TabInfo;
TabOptions m_TabOptions;
TabAdvanced m_TabAdvanced;
std::wstring m_BackupTime;
// Info tab
std::wstring m_Name;
std::wstring m_Author;
std::wstring m_Version;
std::pair<std::wstring, std::wstring> m_SkinFolder;
std::map<std::wstring, std::wstring> m_LayoutFolders;
std::map<std::wstring, std::pair<std::wstring, std::wstring>> m_PluginFolders;
// Options tab
std::wstring m_TargetFile;
std::wstring m_MinimumRainmeter;
std::wstring m_MinimumWindows;
bool m_LoadLayout;
std::wstring m_Load;
// Advanced tab
std::wstring m_HeaderFile;
std::wstring m_VariableFiles;
bool m_MergeSkins;
HANDLE m_PackagerThread;
zipFile m_ZipFile;
bool m_AllowNonAsciiFilenames;
};
#endif
/*
Copyright (C) 2012 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SKININSTALLER_DIALOGPACKAGE_H_
#define SKININSTALLER_DIALOGPACKAGE_H_
#include <string>
#include "zip.h"
#include "../Library/Dialog.h"
class DialogPackage : public Dialog
{
public:
static void Create(HINSTANCE hInstance, LPWSTR lpCmdLine);
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnInitDialog(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
static DialogPackage* c_Dialog;
protected:
virtual Tab& GetActiveTab();
private:
class TabInfo : public Tab
{
public:
TabInfo(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
};
class TabOptions : public Tab
{
public:
TabOptions(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
};
class TabAdvanced : public Tab
{
public:
TabAdvanced(HWND window);
virtual void Initialize();
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
};
DialogPackage(HWND wnd);
virtual ~DialogPackage();
void SetNextButtonState();
bool CreatePackage();
static unsigned __stdcall PackagerThreadProc(void* pParam);
bool AddFileToPackage(const WCHAR* realPath, const WCHAR* zipPath);
bool AddFolderToPackage(const std::wstring& path, std::wstring base, const WCHAR* zipPrefix);
void ShowHelp();
static std::wstring SelectFolder(HWND parent, const std::wstring& existingPath);
static INT_PTR CALLBACK SelectFolderDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static std::pair<std::wstring, std::wstring> SelectPlugin(HWND parent);
static INT_PTR CALLBACK SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
TabInfo m_TabInfo;
TabOptions m_TabOptions;
TabAdvanced m_TabAdvanced;
std::wstring m_BackupTime;
// Info tab
std::wstring m_Name;
std::wstring m_Author;
std::wstring m_Version;
std::pair<std::wstring, std::wstring> m_SkinFolder;
std::map<std::wstring, std::wstring> m_LayoutFolders;
std::map<std::wstring, std::pair<std::wstring, std::wstring>> m_PluginFolders;
// Options tab
std::wstring m_TargetFile;
std::wstring m_MinimumRainmeter;
std::wstring m_MinimumWindows;
bool m_LoadLayout;
std::wstring m_Load;
// Advanced tab
std::wstring m_HeaderFile;
std::wstring m_VariableFiles;
bool m_MergeSkins;
HANDLE m_PackagerThread;
zipFile m_ZipFile;
bool m_AllowNonAsciiFilenames;
};
#endif

View File

@ -1,336 +1,336 @@
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "StdAfx.h"
#include "DialogPackage.h"
#include "DialogInstall.h"
#include "resource.h"
#include "SkinInstaller.h"
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
GlobalData g_Data;
OsNameVersion g_OsNameVersions[] =
{
{ L"XP", L"5.1" },
{ L"Vista", L"6.0" },
{ L"7", L"6.1" },
// { L"8", L"6.2" }
};
/*
** Entry point
**
*/
int SkinInstallerMain(LPWSTR lpCmdLine)
{
// Avoid loading a dll from current directory
SetDllDirectory(L"");
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
InitCommonControls();
if (lpCmdLine[0] == L'"')
{
// Strip quotes
++lpCmdLine;
WCHAR* pos = wcsrchr(lpCmdLine, L'"');
if (pos)
{
*pos = L'\0';
}
}
WCHAR buffer[MAX_PATH];
GetModuleFileName(GetInstanceHandle(), buffer, MAX_PATH);
// Remove the module's name from the path
WCHAR* pos = wcsrchr(buffer, L'\\');
if (pos)
{
*(pos + 1) = L'\0';
}
g_Data.programPath = g_Data.settingsPath = buffer;
wcscat(buffer, L"Rainmeter.ini");
// Find the settings file and read skins path off it
if (_waccess(buffer, 0) == 0)
{
g_Data.iniFile = buffer;
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, buffer) > 0)
{
g_Data.skinsPath = buffer;
if (g_Data.skinsPath.back() != L'\\' && g_Data.skinsPath.back() != L'/')
{
g_Data.skinsPath += L'\\';
}
}
else
{
g_Data.skinsPath = g_Data.programPath;
g_Data.skinsPath += L"Skins\\";
}
}
else
{
HRESULT hr = SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, buffer);
wcscat(buffer, L"\\Rainmeter\\");
g_Data.settingsPath = buffer;
wcscat(buffer, L"Rainmeter.ini");
g_Data.iniFile = buffer;
if (SUCCEEDED(hr) && _waccess(buffer, 0) == 0)
{
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, buffer) > 0)
{
g_Data.skinsPath = buffer;
if (g_Data.skinsPath.back() != L'\\' && g_Data.skinsPath.back() != L'/')
{
g_Data.skinsPath += L'\\';
}
}
else
{
std::wstring error = L"SkinPath not found.\nMake sure that Rainmeter has been run at least once.";
MessageBox(nullptr, error.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
return 1;
}
}
else
{
std::wstring error = L"Rainmeter.ini not found.\nMake sure that Rainmeter has been run at least once.";
MessageBox(nullptr, error.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
return 1;
}
}
std::wstring layoutsPath = g_Data.settingsPath + L"Layouts\\";
if (_waccess(layoutsPath.c_str(), 0) == -1)
{
// Migrate Themes into Layouts for backwards compatibility and rename
// Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp.
std::wstring themesPath = g_Data.settingsPath + L"Themes";
if (_waccess(themesPath.c_str(), 0) != -1)
{
// Migrate Themes into Layouts for backwards compatibility and rename
// Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp.
MoveFile(themesPath.c_str(), layoutsPath.c_str());
layoutsPath += L'*'; // For FindFirstFile.
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(layoutsPath.c_str(), &fd);
layoutsPath.pop_back(); // Remove '*'.
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
wcscmp(L".", fd.cFileName) != 0 &&
wcscmp(L"..", fd.cFileName) != 0)
{
std::wstring layoutFolder = layoutsPath + fd.cFileName;
layoutFolder += L'\\';
std::wstring file = layoutFolder + L"Rainmeter.thm";
if (_waccess(file.c_str(), 0) != -1)
{
std::wstring newFile = layoutFolder + L"Rainmeter.ini";
MoveFile(file.c_str(), newFile.c_str());
}
file = layoutFolder + L"RainThemes.bmp";
if (_waccess(file.c_str(), 0) != -1)
{
std::wstring newFile = layoutFolder + L"Wallpaper.bmp";
MoveFile(file.c_str(), newFile.c_str());
}
}
}
while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
}
if (_wcsnicmp(lpCmdLine, L"/LoadTheme ", 11) == 0)
{
// For backwards compatibility.
std::wstring args = L"!LoadLayout \"";
args += &lpCmdLine[11]; // Skip "/LoadTheme ".
args += L'"';
std::wstring file = g_Data.programPath + L"Rainmeter.exe";
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_UNICODE;
sei.lpFile = file.c_str();
sei.lpParameters = args.c_str();
sei.lpDirectory = g_Data.programPath.c_str();
sei.nShow = SW_SHOWNORMAL;
ShellExecuteEx(&sei);
return 0;
}
else if (wcscmp(lpCmdLine, L"/Packager") == 0)
{
DialogPackage::Create(GetInstanceHandle(), lpCmdLine);
}
else
{
DialogInstall::Create(GetInstanceHandle(), lpCmdLine);
}
return 0;
}
bool CloseRainmeterIfActive()
{
// Close Rainmeter.exe
HWND hwnd = FindWindow(L"DummyRainWClass", L"Rainmeter control window");
if (hwnd)
{
DWORD pID, exitCode;
GetWindowThreadProcessId(hwnd, &pID);
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, pID);
PostMessage(hwnd, WM_DESTROY, 0, 0);
// Wait up to 5 seconds for Rainmeter to close
WaitForSingleObject(hProcess, 5000);
GetExitCodeProcess(hProcess, &exitCode);
CloseHandle(hProcess);
if (exitCode == STILL_ACTIVE)
{
return false;
}
}
return true;
}
HINSTANCE GetInstanceHandle()
{
return (HINSTANCE)&__ImageBase;
}
// -----------------------------------------------------------------------------------------------
// Stolen functions from Rainmeter Litestep.cpp, System.cpp, and Application.cpp
// -----------------------------------------------------------------------------------------------
bool IsRunning(const WCHAR* name, HANDLE* hMutex)
{
// Create mutex
HANDLE hMutexTmp = CreateMutex(nullptr, FALSE, name);
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
*hMutex = nullptr;
return true;
}
else
{
*hMutex = hMutexTmp;
return false;
}
}
bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove)
{
std::wstring tmpFrom(strFrom), tmpTo(strTo);
// The strings must end with double nul
tmpFrom.append(1, L'\0');
tmpTo.append(1, L'\0');
SHFILEOPSTRUCT fo =
{
nullptr,
bMove ? FO_MOVE : FO_COPY,
tmpFrom.c_str(),
tmpTo.c_str(),
FOF_NO_UI | FOF_NOCONFIRMATION | FOF_ALLOWUNDO
};
return SHFileOperation(&fo) == 0;
}
OSPLATFORM GetOSPlatform()
{
OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)};
if (GetVersionEx((OSVERSIONINFO*)&osvi))
{
if (osvi.dwMajorVersion == 5)
{
// Not checking for osvi.dwMinorVersion >= 1 because Rainmeter won't run on pre-XP
return OSPLATFORM_XP;
}
else if (osvi.dwMajorVersion == 6)
{
if (osvi.dwMinorVersion == 0)
{
return OSPLATFORM_VISTA; // Vista, Server 2008
}
else
{
return OSPLATFORM_7; // 7, Server 2008R2
}
}
else // newer OS
{
return OSPLATFORM_7;
}
}
return OSPLATFORM_UNKNOWN;
}
std::string ConvertToAscii(LPCTSTR str)
{
std::string szAscii;
if (str && *str)
{
int strLen = (int)wcslen(str);
int bufLen = WideCharToMultiByte(CP_ACP, 0, str, strLen, nullptr, 0, nullptr, nullptr);
if (bufLen > 0)
{
szAscii.resize(bufLen);
WideCharToMultiByte(CP_ACP, 0, str, strLen, &szAscii[0], bufLen, nullptr, nullptr);
}
}
return szAscii;
}
std::wstring ConvertToWide(LPCSTR str)
{
std::wstring szWide;
if (str && *str)
{
int strLen = (int)strlen(str);
int bufLen = MultiByteToWideChar(CP_ACP, 0, str, strLen, nullptr, 0);
if (bufLen > 0)
{
szWide.resize(bufLen);
MultiByteToWideChar(CP_ACP, 0, str, strLen, &szWide[0], bufLen);
}
}
return szWide;
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "StdAfx.h"
#include "DialogPackage.h"
#include "DialogInstall.h"
#include "resource.h"
#include "SkinInstaller.h"
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
GlobalData g_Data;
OsNameVersion g_OsNameVersions[] =
{
{ L"XP", L"5.1" },
{ L"Vista", L"6.0" },
{ L"7", L"6.1" },
// { L"8", L"6.2" }
};
/*
** Entry point
**
*/
int SkinInstallerMain(LPWSTR lpCmdLine)
{
// Avoid loading a dll from current directory
SetDllDirectory(L"");
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
InitCommonControls();
if (lpCmdLine[0] == L'"')
{
// Strip quotes
++lpCmdLine;
WCHAR* pos = wcsrchr(lpCmdLine, L'"');
if (pos)
{
*pos = L'\0';
}
}
WCHAR buffer[MAX_PATH];
GetModuleFileName(GetInstanceHandle(), buffer, MAX_PATH);
// Remove the module's name from the path
WCHAR* pos = wcsrchr(buffer, L'\\');
if (pos)
{
*(pos + 1) = L'\0';
}
g_Data.programPath = g_Data.settingsPath = buffer;
wcscat(buffer, L"Rainmeter.ini");
// Find the settings file and read skins path off it
if (_waccess(buffer, 0) == 0)
{
g_Data.iniFile = buffer;
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, buffer) > 0)
{
g_Data.skinsPath = buffer;
if (g_Data.skinsPath.back() != L'\\' && g_Data.skinsPath.back() != L'/')
{
g_Data.skinsPath += L'\\';
}
}
else
{
g_Data.skinsPath = g_Data.programPath;
g_Data.skinsPath += L"Skins\\";
}
}
else
{
HRESULT hr = SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, buffer);
wcscat(buffer, L"\\Rainmeter\\");
g_Data.settingsPath = buffer;
wcscat(buffer, L"Rainmeter.ini");
g_Data.iniFile = buffer;
if (SUCCEEDED(hr) && _waccess(buffer, 0) == 0)
{
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, buffer) > 0)
{
g_Data.skinsPath = buffer;
if (g_Data.skinsPath.back() != L'\\' && g_Data.skinsPath.back() != L'/')
{
g_Data.skinsPath += L'\\';
}
}
else
{
std::wstring error = L"SkinPath not found.\nMake sure that Rainmeter has been run at least once.";
MessageBox(nullptr, error.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
return 1;
}
}
else
{
std::wstring error = L"Rainmeter.ini not found.\nMake sure that Rainmeter has been run at least once.";
MessageBox(nullptr, error.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
return 1;
}
}
std::wstring layoutsPath = g_Data.settingsPath + L"Layouts\\";
if (_waccess(layoutsPath.c_str(), 0) == -1)
{
// Migrate Themes into Layouts for backwards compatibility and rename
// Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp.
std::wstring themesPath = g_Data.settingsPath + L"Themes";
if (_waccess(themesPath.c_str(), 0) != -1)
{
// Migrate Themes into Layouts for backwards compatibility and rename
// Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp.
MoveFile(themesPath.c_str(), layoutsPath.c_str());
layoutsPath += L'*'; // For FindFirstFile.
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(layoutsPath.c_str(), &fd);
layoutsPath.pop_back(); // Remove '*'.
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
wcscmp(L".", fd.cFileName) != 0 &&
wcscmp(L"..", fd.cFileName) != 0)
{
std::wstring layoutFolder = layoutsPath + fd.cFileName;
layoutFolder += L'\\';
std::wstring file = layoutFolder + L"Rainmeter.thm";
if (_waccess(file.c_str(), 0) != -1)
{
std::wstring newFile = layoutFolder + L"Rainmeter.ini";
MoveFile(file.c_str(), newFile.c_str());
}
file = layoutFolder + L"RainThemes.bmp";
if (_waccess(file.c_str(), 0) != -1)
{
std::wstring newFile = layoutFolder + L"Wallpaper.bmp";
MoveFile(file.c_str(), newFile.c_str());
}
}
}
while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
}
if (_wcsnicmp(lpCmdLine, L"/LoadTheme ", 11) == 0)
{
// For backwards compatibility.
std::wstring args = L"!LoadLayout \"";
args += &lpCmdLine[11]; // Skip "/LoadTheme ".
args += L'"';
std::wstring file = g_Data.programPath + L"Rainmeter.exe";
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_UNICODE;
sei.lpFile = file.c_str();
sei.lpParameters = args.c_str();
sei.lpDirectory = g_Data.programPath.c_str();
sei.nShow = SW_SHOWNORMAL;
ShellExecuteEx(&sei);
return 0;
}
else if (wcscmp(lpCmdLine, L"/Packager") == 0)
{
DialogPackage::Create(GetInstanceHandle(), lpCmdLine);
}
else
{
DialogInstall::Create(GetInstanceHandle(), lpCmdLine);
}
return 0;
}
bool CloseRainmeterIfActive()
{
// Close Rainmeter.exe
HWND hwnd = FindWindow(L"DummyRainWClass", L"Rainmeter control window");
if (hwnd)
{
DWORD pID, exitCode;
GetWindowThreadProcessId(hwnd, &pID);
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, pID);
PostMessage(hwnd, WM_DESTROY, 0, 0);
// Wait up to 5 seconds for Rainmeter to close
WaitForSingleObject(hProcess, 5000);
GetExitCodeProcess(hProcess, &exitCode);
CloseHandle(hProcess);
if (exitCode == STILL_ACTIVE)
{
return false;
}
}
return true;
}
HINSTANCE GetInstanceHandle()
{
return (HINSTANCE)&__ImageBase;
}
// -----------------------------------------------------------------------------------------------
// Stolen functions from Rainmeter Litestep.cpp, System.cpp, and Application.cpp
// -----------------------------------------------------------------------------------------------
bool IsRunning(const WCHAR* name, HANDLE* hMutex)
{
// Create mutex
HANDLE hMutexTmp = CreateMutex(nullptr, FALSE, name);
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
*hMutex = nullptr;
return true;
}
else
{
*hMutex = hMutexTmp;
return false;
}
}
bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove)
{
std::wstring tmpFrom(strFrom), tmpTo(strTo);
// The strings must end with double nul
tmpFrom.append(1, L'\0');
tmpTo.append(1, L'\0');
SHFILEOPSTRUCT fo =
{
nullptr,
bMove ? FO_MOVE : FO_COPY,
tmpFrom.c_str(),
tmpTo.c_str(),
FOF_NO_UI | FOF_NOCONFIRMATION | FOF_ALLOWUNDO
};
return SHFileOperation(&fo) == 0;
}
OSPLATFORM GetOSPlatform()
{
OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)};
if (GetVersionEx((OSVERSIONINFO*)&osvi))
{
if (osvi.dwMajorVersion == 5)
{
// Not checking for osvi.dwMinorVersion >= 1 because Rainmeter won't run on pre-XP
return OSPLATFORM_XP;
}
else if (osvi.dwMajorVersion == 6)
{
if (osvi.dwMinorVersion == 0)
{
return OSPLATFORM_VISTA; // Vista, Server 2008
}
else
{
return OSPLATFORM_7; // 7, Server 2008R2
}
}
else // newer OS
{
return OSPLATFORM_7;
}
}
return OSPLATFORM_UNKNOWN;
}
std::string ConvertToAscii(LPCTSTR str)
{
std::string szAscii;
if (str && *str)
{
int strLen = (int)wcslen(str);
int bufLen = WideCharToMultiByte(CP_ACP, 0, str, strLen, nullptr, 0, nullptr, nullptr);
if (bufLen > 0)
{
szAscii.resize(bufLen);
WideCharToMultiByte(CP_ACP, 0, str, strLen, &szAscii[0], bufLen, nullptr, nullptr);
}
}
return szAscii;
}
std::wstring ConvertToWide(LPCSTR str)
{
std::wstring szWide;
if (str && *str)
{
int strLen = (int)strlen(str);
int bufLen = MultiByteToWideChar(CP_ACP, 0, str, strLen, nullptr, 0);
if (bufLen > 0)
{
szWide.resize(bufLen);
MultiByteToWideChar(CP_ACP, 0, str, strLen, &szWide[0], bufLen);
}
}
return szWide;
}

View File

@ -1,4 +1,4 @@
LIBRARY
EXPORTS
; Private
SkinInstallerMain @1 NONAME
LIBRARY
EXPORTS
; Private
SkinInstallerMain @1 NONAME

View File

@ -1,61 +1,61 @@
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SKININSTALLER_UTIL_H_
#define SKININSTALLER_UTIL_H_
#include <string>
#include "zip.h"
#include "unzip.h"
#define MAX_LINE_LENGTH 4096
#define MB_ERROR MB_OK | MB_TOPMOST | MB_ICONERROR
struct GlobalData
{
std::wstring programPath;
std::wstring settingsPath;
std::wstring skinsPath;
std::wstring iniFile;
};
struct OsNameVersion
{
const WCHAR* name;
const WCHAR* version;
};
enum OSPLATFORM
{
OSPLATFORM_UNKNOWN = 0,
OSPLATFORM_XP,
OSPLATFORM_VISTA,
OSPLATFORM_7
};
HINSTANCE GetInstanceHandle();
bool CloseRainmeterIfActive();
OSPLATFORM GetOSPlatform();
bool IsRunning(const WCHAR* name, HANDLE* hMutex);
bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
std::string ConvertToAscii(LPCTSTR str);
std::wstring ConvertToWide(LPCSTR str);
#endif
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SKININSTALLER_UTIL_H_
#define SKININSTALLER_UTIL_H_
#include <string>
#include "zip.h"
#include "unzip.h"
#define MAX_LINE_LENGTH 4096
#define MB_ERROR MB_OK | MB_TOPMOST | MB_ICONERROR
struct GlobalData
{
std::wstring programPath;
std::wstring settingsPath;
std::wstring skinsPath;
std::wstring iniFile;
};
struct OsNameVersion
{
const WCHAR* name;
const WCHAR* version;
};
enum OSPLATFORM
{
OSPLATFORM_UNKNOWN = 0,
OSPLATFORM_XP,
OSPLATFORM_VISTA,
OSPLATFORM_7
};
HINSTANCE GetInstanceHandle();
bool CloseRainmeterIfActive();
OSPLATFORM GetOSPlatform();
bool IsRunning(const WCHAR* name, HANDLE* hMutex);
bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
std::string ConvertToAscii(LPCTSTR str);
std::wstring ConvertToWide(LPCSTR str);
#endif

View File

@ -1,199 +1,199 @@
#include <Windows.h>
#include "resource.h"
#include "../Version.h"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILEVER
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileDescription", "Rainmeter Skin Installer"
VALUE "FileVersion", STRFILEVER
VALUE "LegalCopyright", "<22> 2013 - All authors"
VALUE "OriginalFilename", "SkinInstaller.dll"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
#else
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
#endif //_WIN64
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_INSTALL_MENU MENU
{
POPUP " "
{
MENUITEM "Backup skins", IDM_INSTALL_BACKUPSKINS
MENUITEM "Install fonts to system", IDM_INSTALL_SYSTEMFONTS, GRAYED
MENUITEM SEPARATOR
MENUITEM " ", IDM_INSTALL_FORMAT, GRAYED
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PACKAGE_DIALOG DIALOGEX 0, 0, 300, 280
STYLE DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rainmeter Skin Packager"
FONT 8, "MS Shell Dlg 2"
{
CONTROL "", IDC_PACKAGE_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 6, 288, 251
DEFPUSHBUTTON "Next", IDC_PACKAGE_NEXT_BUTTON, 188, 261, 50, 14, WS_DISABLED
PUSHBUTTON "Create package", IDC_PACKAGE_CREATEPACKAGE_BUTTON, 158, 261, 80, 14, NOT WS_VISIBLE
PUSHBUTTON "Cancel", IDCANCEL, 243, 261, 50, 14
}
IDD_PACKAGEINFO_TAB DIALOGEX 15, 15, 270, 235
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Enter the information and select the components to use for the .rmskin package.", IDC_STATIC, 0, 0, 264, 19
GROUPBOX "Information", IDC_STATIC, 0, 35, 270, 70
LTEXT "Name:", IDC_STATIC, 6, 51, 35, 9
EDITTEXT IDC_PACKAGEINFO_NAME_EDIT, 56, 48, 208, 14
LTEXT "Author:", IDC_STATIC, 6, 69, 35, 9
EDITTEXT IDC_PACKAGEINFO_AUTHOR_EDIT, 56, 66, 208, 14
LTEXT "Version:", IDC_STATIC, 6, 87, 35, 9
EDITTEXT IDC_PACKAGEINFO_VERSION_EDIT, 56, 83, 140, 14
GROUPBOX "Components", IDC_STATIC, 0, 110, 270, 108
CONTROL "", IDC_PACKAGEINFO_COMPONENTS_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 6, 125, 182, 86
PUSHBUTTON "Add skin...", IDC_PACKAGEINFO_ADDSKIN_BUTTON, 194, 125, 70, 14
PUSHBUTTON "Add layout...", IDC_PACKAGEINFO_ADDTHEME_BUTTON, 194, 144, 70, 14
PUSHBUTTON "Add plugin...", IDC_PACKAGEINFO_ADDPLUGIN_BUTTON, 194, 162, 70, 14
PUSHBUTTON "Remove", IDC_PACKAGEINFO_REMOVE_BUTTON, 194, 197, 70, 14, WS_DISABLED
CONTROL "<A>What is a .rmskin package?</A>", IDC_PACKAGEINFO_WHATIS_LINK, "SysLink", 0x0, 0, 225, 264, 9
}
IDD_PACKAGEOPTIONS_TAB DIALOGEX 15, 30, 270, 220
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Save package to:", IDC_STATIC, 0, 0, 264, 9
EDITTEXT IDC_PACKAGEOPTIONS_FILE_EDIT, 0, 17, 240, 14, ES_READONLY | ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
PUSHBUTTON "...", IDC_PACKAGEOPTIONS_FILEBROWSE_BUTTON, 245, 17, 25, 14, WS_TABSTOP
GROUPBOX "After installation", IDC_STATIC, 0, 101, 270, 58
AUTORADIOBUTTON "Do nothing", IDC_PACKAGEOPTIONS_DONOTHING_RADIO, 6, 116, 85, 9, WS_TABSTOP
AUTORADIOBUTTON "Load skin", IDC_PACKAGEOPTIONS_LOADSKIN_RADIO, 6, 129, 85, 9, WS_TABSTOP
EDITTEXT IDC_PACKAGEOPTIONS_LOADSKIN_EDIT, 96, 126, 138, 14, ES_READONLY | ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | NOT WS_VISIBLE
PUSHBUTTON "...", IDC_PACKAGEOPTIONS_LOADSKINBROWSE_BUTTON, 239, 126, 25, 14, WS_TABSTOP | NOT WS_VISIBLE
AUTORADIOBUTTON "Load layout", IDC_PACKAGEOPTIONS_LOADTHEME_RADIO, 6, 142, 85, 9, WS_TABSTOP
COMBOBOX IDC_PACKAGEOPTIONS_LOADTHEME_COMBO, 96, 139, 168, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | NOT WS_VISIBLE
GROUPBOX "Minimum requirements", IDC_STATIC, 0, 164, 270, 53
LTEXT "Rainmeter version:", IDC_STATIC, 6, 180, 85, 9
EDITTEXT IDC_PACKAGEOPTIONS_RAINMETERVERSION_EDIT, 96, 177, 80, 14
LTEXT "Windows version:", IDC_STATIC, 6, 198, 85, 9
COMBOBOX IDC_PACKAGEOPTIONS_WINDOWSVERSION_COMBO, 96, 195, 80, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Creating...", IDC_INSTALLTAB_CREATING_TEXT, 0, 0, 270, 100, NOT WS_VISIBLE
CONTROL "", IDC_INSTALLTAB_CREATING_BAR, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 270, 11
}
IDD_PACKAGEADVANCED_TAB DIALOGEX 15, 30, 270, 220
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Header image:", IDC_STATIC, 0, 3, 85, 9
EDITTEXT IDC_PACKAGEADVANCED_HEADER_EDIT, 90, 0, 150, 14, ES_READONLY | ES_AUTOHSCROLL | WS_TABSTOP
PUSHBUTTON "...", IDC_PACKAGEADVANCED_HEADERROWSE_BUTTON, 245, 0, 25, 14, WS_TABSTOP
LTEXT "Variables files:", IDC_STATIC, 0, 24, 85, 9
EDITTEXT IDC_PACKAGEADVANCED_VARIABLEFILES_EDIT, 90, 21, 180, 14, ES_AUTOHSCROLL | WS_TABSTOP
AUTOCHECKBOX "Merge skins", IDC_PACKAGEADVANCED_MERGESKINS_CHECK, 0, 42, 85, 9, WS_TABSTOP
CONTROL "<A>Help</A>", IDC_PACKAGEADVANCED_HELP_LINK, "SysLink", 0x0, 0, 210, 264, 9
}
IDD_PACKAGESELECTFOLDER_DIALOG DIALOGEX 0, 0, 200, 100
STYLE DS_CENTER | WS_POPUP | WS_TILEDWINDOW
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Add"
FONT 8, "MS Shell Dlg 2"
{
AUTORADIOBUTTON "", IDC_PACKAGESELECTFOLDER_EXISTING_RADIO, 6, 6, 220, 9, WS_TABSTOP | BST_CHECKED
COMBOBOX IDC_PACKAGESELECTFOLDER_EXISTING_COMBO, 16, 19, 177, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
AUTORADIOBUTTON "Add custom folder:", IDC_PACKAGESELECTFOLDER_CUSTOM_RADIO, 6, 40, 220, 9, WS_TABSTOP
EDITTEXT IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT, 16, 53, 149, 14, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | WS_DISABLED
PUSHBUTTON "...", IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON, 170, 53, 25, 14, WS_TABSTOP | WS_DISABLED
DEFPUSHBUTTON "Add", IDOK, 146, 82, 50, 14
}
IDD_PACKAGESELECTPLUGIN_DIALOG DIALOGEX 0, 0, 200, 100
STYLE DS_CENTER | WS_POPUP | WS_TILEDWINDOW
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Add"
FONT 8, "MS Shell Dlg 2"
{
LTEXT "32-bit DLL:", IDC_STATIC, 6, 6, 220, 9
EDITTEXT IDC_PACKAGESELECTPLUGIN_32BIT_EDIT, 16, 19, 149, 14, ES_READONLY | WS_BORDER
PUSHBUTTON "...", IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON, 170, 19, 25, 14, WS_TABSTOP
LTEXT "64-bit DLL:", IDC_STATIC, 6, 40, 220, 9
EDITTEXT IDC_PACKAGESELECTPLUGIN_64BIT_EDIT, 16, 53, 149, 14, ES_READONLY | WS_BORDER
PUSHBUTTON "...", IDC_PACKAGESELECTPLUGIN_64BITBROWSE_BUTTON, 170, 53, 25, 14, WS_TABSTOP
DEFPUSHBUTTON "Add", IDOK, 146, 82, 50, 14, WS_DISABLED
}
IDD_INSTALL_DIALOG DIALOGEX 0, 0, 266, 250
STYLE DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rainmeter Skin Installer"
FONT 8, "MS Shell Dlg 2"
{
CONTROL 0, IDC_INSTALL_HEADER_BITMAP, STATIC, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 266, 37
CONTROL "", IDC_INSTALL_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 42, 254, 185
PUSHBUTTON "Advanced", IDC_INSTALL_ADVANCED_BUTTON, 6, 231, 70, 14
DEFPUSHBUTTON "Install", IDC_INSTALL_INSTALL_BUTTON, 155, 231, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 210, 231, 50, 14
}
IDD_INSTALL_TAB DIALOGEX 15, 51, 236, 168
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Name:", IDC_STATIC, 0, 0, 35, 9
LTEXT "", IDC_INSTALLTAB_NAME_TEXT, 50, 0, 200, 9, SS_NOPREFIX
LTEXT "Author:", IDC_STATIC, 0, 13, 35, 9
LTEXT "", IDC_INSTALLTAB_AUTHOR_TEXT, 50, 13, 200, 9, SS_NOPREFIX
LTEXT "Version:", IDC_STATIC, 0, 26, 35, 9
LTEXT "", IDC_INSTALLTAB_VERSION_TEXT, 50, 26, 200, 9, SS_NOPREFIX
LTEXT "Included components:", IDC_STATIC, 0, 45, 80, 9
CONTROL "", IDC_INSTALLTAB_COMPONENTS_LIST, "SysListView32", LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 0, 60, 234, 86
AUTOCHECKBOX "Apply included layout", IDC_INSTALLTAB_THEME_CHECKBOX, 4, 155, 220, 9
LTEXT "Installing...", IDC_INSTALLTAB_INPROGRESS_TEXT, 0, 0, 236, 60, NOT WS_VISIBLE
CONTROL "", IDC_INSTALLTAB_PROGRESS, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 236, 11
}
#include <Windows.h>
#include "resource.h"
#include "../Version.h"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILEVER
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileDescription", "Rainmeter Skin Installer"
VALUE "FileVersion", STRFILEVER
VALUE "LegalCopyright", "<22> 2013 - All authors"
VALUE "OriginalFilename", "SkinInstaller.dll"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
#else
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
#endif //_WIN64
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_INSTALL_MENU MENU
{
POPUP " "
{
MENUITEM "Backup skins", IDM_INSTALL_BACKUPSKINS
MENUITEM "Install fonts to system", IDM_INSTALL_SYSTEMFONTS, GRAYED
MENUITEM SEPARATOR
MENUITEM " ", IDM_INSTALL_FORMAT, GRAYED
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PACKAGE_DIALOG DIALOGEX 0, 0, 300, 280
STYLE DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rainmeter Skin Packager"
FONT 8, "MS Shell Dlg 2"
{
CONTROL "", IDC_PACKAGE_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 6, 288, 251
DEFPUSHBUTTON "Next", IDC_PACKAGE_NEXT_BUTTON, 188, 261, 50, 14, WS_DISABLED
PUSHBUTTON "Create package", IDC_PACKAGE_CREATEPACKAGE_BUTTON, 158, 261, 80, 14, NOT WS_VISIBLE
PUSHBUTTON "Cancel", IDCANCEL, 243, 261, 50, 14
}
IDD_PACKAGEINFO_TAB DIALOGEX 15, 15, 270, 235
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Enter the information and select the components to use for the .rmskin package.", IDC_STATIC, 0, 0, 264, 19
GROUPBOX "Information", IDC_STATIC, 0, 35, 270, 70
LTEXT "Name:", IDC_STATIC, 6, 51, 35, 9
EDITTEXT IDC_PACKAGEINFO_NAME_EDIT, 56, 48, 208, 14
LTEXT "Author:", IDC_STATIC, 6, 69, 35, 9
EDITTEXT IDC_PACKAGEINFO_AUTHOR_EDIT, 56, 66, 208, 14
LTEXT "Version:", IDC_STATIC, 6, 87, 35, 9
EDITTEXT IDC_PACKAGEINFO_VERSION_EDIT, 56, 83, 140, 14
GROUPBOX "Components", IDC_STATIC, 0, 110, 270, 108
CONTROL "", IDC_PACKAGEINFO_COMPONENTS_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 6, 125, 182, 86
PUSHBUTTON "Add skin...", IDC_PACKAGEINFO_ADDSKIN_BUTTON, 194, 125, 70, 14
PUSHBUTTON "Add layout...", IDC_PACKAGEINFO_ADDTHEME_BUTTON, 194, 144, 70, 14
PUSHBUTTON "Add plugin...", IDC_PACKAGEINFO_ADDPLUGIN_BUTTON, 194, 162, 70, 14
PUSHBUTTON "Remove", IDC_PACKAGEINFO_REMOVE_BUTTON, 194, 197, 70, 14, WS_DISABLED
CONTROL "<A>What is a .rmskin package?</A>", IDC_PACKAGEINFO_WHATIS_LINK, "SysLink", 0x0, 0, 225, 264, 9
}
IDD_PACKAGEOPTIONS_TAB DIALOGEX 15, 30, 270, 220
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Save package to:", IDC_STATIC, 0, 0, 264, 9
EDITTEXT IDC_PACKAGEOPTIONS_FILE_EDIT, 0, 17, 240, 14, ES_READONLY | ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
PUSHBUTTON "...", IDC_PACKAGEOPTIONS_FILEBROWSE_BUTTON, 245, 17, 25, 14, WS_TABSTOP
GROUPBOX "After installation", IDC_STATIC, 0, 101, 270, 58
AUTORADIOBUTTON "Do nothing", IDC_PACKAGEOPTIONS_DONOTHING_RADIO, 6, 116, 85, 9, WS_TABSTOP
AUTORADIOBUTTON "Load skin", IDC_PACKAGEOPTIONS_LOADSKIN_RADIO, 6, 129, 85, 9, WS_TABSTOP
EDITTEXT IDC_PACKAGEOPTIONS_LOADSKIN_EDIT, 96, 126, 138, 14, ES_READONLY | ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | NOT WS_VISIBLE
PUSHBUTTON "...", IDC_PACKAGEOPTIONS_LOADSKINBROWSE_BUTTON, 239, 126, 25, 14, WS_TABSTOP | NOT WS_VISIBLE
AUTORADIOBUTTON "Load layout", IDC_PACKAGEOPTIONS_LOADTHEME_RADIO, 6, 142, 85, 9, WS_TABSTOP
COMBOBOX IDC_PACKAGEOPTIONS_LOADTHEME_COMBO, 96, 139, 168, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | NOT WS_VISIBLE
GROUPBOX "Minimum requirements", IDC_STATIC, 0, 164, 270, 53
LTEXT "Rainmeter version:", IDC_STATIC, 6, 180, 85, 9
EDITTEXT IDC_PACKAGEOPTIONS_RAINMETERVERSION_EDIT, 96, 177, 80, 14
LTEXT "Windows version:", IDC_STATIC, 6, 198, 85, 9
COMBOBOX IDC_PACKAGEOPTIONS_WINDOWSVERSION_COMBO, 96, 195, 80, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Creating...", IDC_INSTALLTAB_CREATING_TEXT, 0, 0, 270, 100, NOT WS_VISIBLE
CONTROL "", IDC_INSTALLTAB_CREATING_BAR, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 270, 11
}
IDD_PACKAGEADVANCED_TAB DIALOGEX 15, 30, 270, 220
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Header image:", IDC_STATIC, 0, 3, 85, 9
EDITTEXT IDC_PACKAGEADVANCED_HEADER_EDIT, 90, 0, 150, 14, ES_READONLY | ES_AUTOHSCROLL | WS_TABSTOP
PUSHBUTTON "...", IDC_PACKAGEADVANCED_HEADERROWSE_BUTTON, 245, 0, 25, 14, WS_TABSTOP
LTEXT "Variables files:", IDC_STATIC, 0, 24, 85, 9
EDITTEXT IDC_PACKAGEADVANCED_VARIABLEFILES_EDIT, 90, 21, 180, 14, ES_AUTOHSCROLL | WS_TABSTOP
AUTOCHECKBOX "Merge skins", IDC_PACKAGEADVANCED_MERGESKINS_CHECK, 0, 42, 85, 9, WS_TABSTOP
CONTROL "<A>Help</A>", IDC_PACKAGEADVANCED_HELP_LINK, "SysLink", 0x0, 0, 210, 264, 9
}
IDD_PACKAGESELECTFOLDER_DIALOG DIALOGEX 0, 0, 200, 100
STYLE DS_CENTER | WS_POPUP | WS_TILEDWINDOW
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Add"
FONT 8, "MS Shell Dlg 2"
{
AUTORADIOBUTTON "", IDC_PACKAGESELECTFOLDER_EXISTING_RADIO, 6, 6, 220, 9, WS_TABSTOP | BST_CHECKED
COMBOBOX IDC_PACKAGESELECTFOLDER_EXISTING_COMBO, 16, 19, 177, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
AUTORADIOBUTTON "Add custom folder:", IDC_PACKAGESELECTFOLDER_CUSTOM_RADIO, 6, 40, 220, 9, WS_TABSTOP
EDITTEXT IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT, 16, 53, 149, 14, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | WS_DISABLED
PUSHBUTTON "...", IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON, 170, 53, 25, 14, WS_TABSTOP | WS_DISABLED
DEFPUSHBUTTON "Add", IDOK, 146, 82, 50, 14
}
IDD_PACKAGESELECTPLUGIN_DIALOG DIALOGEX 0, 0, 200, 100
STYLE DS_CENTER | WS_POPUP | WS_TILEDWINDOW
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Add"
FONT 8, "MS Shell Dlg 2"
{
LTEXT "32-bit DLL:", IDC_STATIC, 6, 6, 220, 9
EDITTEXT IDC_PACKAGESELECTPLUGIN_32BIT_EDIT, 16, 19, 149, 14, ES_READONLY | WS_BORDER
PUSHBUTTON "...", IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON, 170, 19, 25, 14, WS_TABSTOP
LTEXT "64-bit DLL:", IDC_STATIC, 6, 40, 220, 9
EDITTEXT IDC_PACKAGESELECTPLUGIN_64BIT_EDIT, 16, 53, 149, 14, ES_READONLY | WS_BORDER
PUSHBUTTON "...", IDC_PACKAGESELECTPLUGIN_64BITBROWSE_BUTTON, 170, 53, 25, 14, WS_TABSTOP
DEFPUSHBUTTON "Add", IDOK, 146, 82, 50, 14, WS_DISABLED
}
IDD_INSTALL_DIALOG DIALOGEX 0, 0, 266, 250
STYLE DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rainmeter Skin Installer"
FONT 8, "MS Shell Dlg 2"
{
CONTROL 0, IDC_INSTALL_HEADER_BITMAP, STATIC, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 266, 37
CONTROL "", IDC_INSTALL_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 42, 254, 185
PUSHBUTTON "Advanced", IDC_INSTALL_ADVANCED_BUTTON, 6, 231, 70, 14
DEFPUSHBUTTON "Install", IDC_INSTALL_INSTALL_BUTTON, 155, 231, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 210, 231, 50, 14
}
IDD_INSTALL_TAB DIALOGEX 15, 51, 236, 168
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg 2"
{
LTEXT "Name:", IDC_STATIC, 0, 0, 35, 9
LTEXT "", IDC_INSTALLTAB_NAME_TEXT, 50, 0, 200, 9, SS_NOPREFIX
LTEXT "Author:", IDC_STATIC, 0, 13, 35, 9
LTEXT "", IDC_INSTALLTAB_AUTHOR_TEXT, 50, 13, 200, 9, SS_NOPREFIX
LTEXT "Version:", IDC_STATIC, 0, 26, 35, 9
LTEXT "", IDC_INSTALLTAB_VERSION_TEXT, 50, 26, 200, 9, SS_NOPREFIX
LTEXT "Included components:", IDC_STATIC, 0, 45, 80, 9
CONTROL "", IDC_INSTALLTAB_COMPONENTS_LIST, "SysListView32", LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 0, 60, 234, 86
AUTOCHECKBOX "Apply included layout", IDC_INSTALLTAB_THEME_CHECKBOX, 4, 155, 220, 9
LTEXT "Installing...", IDC_INSTALLTAB_INPROGRESS_TEXT, 0, 0, 236, 60, NOT WS_VISIBLE
CONTROL "", IDC_INSTALLTAB_PROGRESS, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 236, 11
}

View File

@ -1,110 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA}</ProjectGuid>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<MASM>
<PreprocessorDefinitions>NOOLDPENTIUMCODE</PreprocessorDefinitions>
</MASM>
<ClCompile>
<PreprocessorDefinitions>ZLIB_WINAPI;NOCRYPT;NOUNCRYPT;NO_GZIP;ASMV;ASMINF;NOOLDPENTIUMCODE;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4244;4267;4482;4530;4996</DisableSpecificWarnings>
<AdditionalIncludeDirectories>./zlib;./zlib/minizip</AdditionalIncludeDirectories>
<ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>Imagehlp.lib;Wininet.lib;Comctl32.lib;Version.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<ModuleDefinitionFile>SkinInstaller.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Common\StringUtil.cpp" />
<ClCompile Include="..\Library\Dialog.cpp" />
<ClCompile Include="DialogInstall.cpp" />
<ClCompile Include="DialogPackage.cpp" />
<ClCompile Include="StdAfx.cpp" />
<ClCompile Include="SkinInstaller.cpp" />
<ClCompile Include="zlib\adler32.c" />
<ClCompile Include="zlib\crc32.c" />
<ClCompile Include="zlib\deflate.c" />
<ClCompile Include="zlib\infback.c" />
<ClCompile Include="zlib\inffas8664.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="zlib\inffast.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="zlib\inflate.c" />
<ClCompile Include="zlib\inftrees.c" />
<ClCompile Include="zlib\minizip\ioapi.c" />
<ClCompile Include="zlib\minizip\iowin32.c" />
<ClCompile Include="zlib\minizip\unzip.c" />
<ClCompile Include="zlib\minizip\zip.c" />
<ClCompile Include="zlib\trees.c" />
<ClCompile Include="zlib\zutil.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstaller.rc">
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Library\Dialog.h" />
<ClInclude Include="DialogInstall.h" />
<ClInclude Include="DialogPackage.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="SkinInstaller.h" />
<ClInclude Include="zlib\crc32.h" />
<ClInclude Include="zlib\deflate.h" />
<ClInclude Include="zlib\inffast.h" />
<ClInclude Include="zlib\inflate.h" />
<ClInclude Include="zlib\inftrees.h" />
<ClInclude Include="zlib\minizip\ioapi.h" />
<ClInclude Include="zlib\minizip\iowin32.h" />
<ClInclude Include="zlib\minizip\unzip.h" />
<ClInclude Include="zlib\minizip\zip.h" />
<ClInclude Include="zlib\zconf.h" />
<ClInclude Include="zlib\zlib.h" />
<ClInclude Include="zlib\zutil.h" />
</ItemGroup>
<ItemGroup>
<MASM Include="zlib\match686.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='x64'">true</ExcludedFromBuild>
</MASM>
<MASM Include="zlib\gvmat64.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
</MASM>
<MASM Include="zlib\inffas32.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='x64'">true</ExcludedFromBuild>
</MASM>
<MASM Include="zlib\inffasx64.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
</MASM>
</ItemGroup>
<ItemGroup>
<None Include="SkinInstaller.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA}</ProjectGuid>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<MASM>
<PreprocessorDefinitions>NOOLDPENTIUMCODE</PreprocessorDefinitions>
</MASM>
<ClCompile>
<PreprocessorDefinitions>ZLIB_WINAPI;NOCRYPT;NOUNCRYPT;NO_GZIP;ASMV;ASMINF;NOOLDPENTIUMCODE;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4244;4267;4482;4530;4996</DisableSpecificWarnings>
<AdditionalIncludeDirectories>./zlib;./zlib/minizip</AdditionalIncludeDirectories>
<ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>Imagehlp.lib;Wininet.lib;Comctl32.lib;Version.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<ModuleDefinitionFile>SkinInstaller.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Common\StringUtil.cpp" />
<ClCompile Include="..\Library\Dialog.cpp" />
<ClCompile Include="DialogInstall.cpp" />
<ClCompile Include="DialogPackage.cpp" />
<ClCompile Include="StdAfx.cpp" />
<ClCompile Include="SkinInstaller.cpp" />
<ClCompile Include="zlib\adler32.c" />
<ClCompile Include="zlib\crc32.c" />
<ClCompile Include="zlib\deflate.c" />
<ClCompile Include="zlib\infback.c" />
<ClCompile Include="zlib\inffas8664.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="zlib\inffast.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="zlib\inflate.c" />
<ClCompile Include="zlib\inftrees.c" />
<ClCompile Include="zlib\minizip\ioapi.c" />
<ClCompile Include="zlib\minizip\iowin32.c" />
<ClCompile Include="zlib\minizip\unzip.c" />
<ClCompile Include="zlib\minizip\zip.c" />
<ClCompile Include="zlib\trees.c" />
<ClCompile Include="zlib\zutil.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstaller.rc">
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Library\Dialog.h" />
<ClInclude Include="DialogInstall.h" />
<ClInclude Include="DialogPackage.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="SkinInstaller.h" />
<ClInclude Include="zlib\crc32.h" />
<ClInclude Include="zlib\deflate.h" />
<ClInclude Include="zlib\inffast.h" />
<ClInclude Include="zlib\inflate.h" />
<ClInclude Include="zlib\inftrees.h" />
<ClInclude Include="zlib\minizip\ioapi.h" />
<ClInclude Include="zlib\minizip\iowin32.h" />
<ClInclude Include="zlib\minizip\unzip.h" />
<ClInclude Include="zlib\minizip\zip.h" />
<ClInclude Include="zlib\zconf.h" />
<ClInclude Include="zlib\zlib.h" />
<ClInclude Include="zlib\zutil.h" />
</ItemGroup>
<ItemGroup>
<MASM Include="zlib\match686.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='x64'">true</ExcludedFromBuild>
</MASM>
<MASM Include="zlib\gvmat64.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
</MASM>
<MASM Include="zlib\inffas32.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='x64'">true</ExcludedFromBuild>
</MASM>
<MASM Include="zlib\inffasx64.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
</MASM>
</ItemGroup>
<ItemGroup>
<None Include="SkinInstaller.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@ -1,168 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{3f37d5c4-4ae6-401f-9453-10dfc5fdb7f7}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{17b931a7-44f0-4e35-a315-8735fefc7099}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{91b7f443-69f2-4af0-8898-79c86916bbc5}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
<Filter Include="zlib">
<UniqueIdentifier>{42a27d72-d4b7-4a2f-9f0b-5d552623914c}</UniqueIdentifier>
</Filter>
<Filter Include="zlib\minizip">
<UniqueIdentifier>{b726e25d-2977-424a-b45b-8ee60ce6bd49}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{b69ece81-b900-41d8-9ccd-61476261c411}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zlib\adler32.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\crc32.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\deflate.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\infback.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inflate.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inftrees.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\trees.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\zutil.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inffast.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inffas8664.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\zip.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\ioapi.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\iowin32.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\unzip.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="..\Library\Dialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DialogInstall.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DialogPackage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Common\StringUtil.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="SkinInstaller.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zlib\zutil.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\crc32.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\deflate.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\inffast.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\inflate.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\inftrees.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\zconf.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\zlib.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\zip.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\ioapi.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\iowin32.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\unzip.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="..\Library\Dialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DialogInstall.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DialogPackage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SkinInstaller.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="SkinInstaller.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<MASM Include="zlib\gvmat64.asm">
<Filter>zlib</Filter>
</MASM>
<MASM Include="zlib\inffasx64.asm">
<Filter>zlib</Filter>
</MASM>
<MASM Include="zlib\inffas32.asm">
<Filter>zlib</Filter>
</MASM>
<MASM Include="zlib\match686.asm">
<Filter>zlib</Filter>
</MASM>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstaller.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{3f37d5c4-4ae6-401f-9453-10dfc5fdb7f7}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{17b931a7-44f0-4e35-a315-8735fefc7099}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{91b7f443-69f2-4af0-8898-79c86916bbc5}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
<Filter Include="zlib">
<UniqueIdentifier>{42a27d72-d4b7-4a2f-9f0b-5d552623914c}</UniqueIdentifier>
</Filter>
<Filter Include="zlib\minizip">
<UniqueIdentifier>{b726e25d-2977-424a-b45b-8ee60ce6bd49}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{b69ece81-b900-41d8-9ccd-61476261c411}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zlib\adler32.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\crc32.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\deflate.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\infback.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inflate.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inftrees.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\trees.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\zutil.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inffast.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\inffas8664.c">
<Filter>zlib</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\zip.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\ioapi.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\iowin32.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="zlib\minizip\unzip.c">
<Filter>zlib\minizip</Filter>
</ClCompile>
<ClCompile Include="..\Library\Dialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DialogInstall.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DialogPackage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Common\StringUtil.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="SkinInstaller.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zlib\zutil.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\crc32.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\deflate.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\inffast.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\inflate.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\inftrees.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\zconf.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\zlib.h">
<Filter>zlib</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\zip.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\ioapi.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\iowin32.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="zlib\minizip\unzip.h">
<Filter>zlib\minizip</Filter>
</ClInclude>
<ClInclude Include="..\Library\Dialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DialogInstall.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DialogPackage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SkinInstaller.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="SkinInstaller.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<MASM Include="zlib\gvmat64.asm">
<Filter>zlib</Filter>
</MASM>
<MASM Include="zlib\inffasx64.asm">
<Filter>zlib</Filter>
</MASM>
<MASM Include="zlib\inffas32.asm">
<Filter>zlib</Filter>
</MASM>
<MASM Include="zlib\match686.asm">
<Filter>zlib</Filter>
</MASM>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstaller.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -1,129 +1,129 @@
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <Windows.h>
#include <Shlwapi.h>
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
typedef int (*SkinInstallerMainFunc)(LPWSTR cmdLine);
WCHAR* GetCommandLineArguments()
{
WCHAR* args = GetCommandLine();
// Skip past (quoted) application path in cmdLine.
if (*args == L'"')
{
++args; // Skip leading quote.
while (*args && *args != L'"')
{
++args;
}
++args; // Skip trailing quote.
}
else
{
while (*args && *args != L' ')
{
++args;
}
}
// Skip leading whitespace (similar to CRT implementation).
while (*args && *args <= L' ')
{
++args;
}
return args;
}
/*
** Attempts to load SkinInstaller.dll. If it fails, retries after loading our own copies of the
** CRT DLLs in the Runtime directory.
*/
HINSTANCE LoadSkinInstallerLibrary()
{
HINSTANCE rmDll = LoadLibrary(L"SkinInstaller.dll");
if (!rmDll)
{
WCHAR path[MAX_PATH];
if (GetModuleFileName(nullptr, path, MAX_PATH) > 0)
{
PathRemoveFileSpec(path);
PathAppend(path, L"Runtime");
SetDllDirectory(path);
PathAppend(path, L"msvcp120.dll");
// Loading msvcpNNN.dll will load msvcrNNN.dll as well.
HINSTANCE msvcrDll = LoadLibrary(path);
SetDllDirectory(L"");
if (msvcrDll)
{
rmDll = LoadLibrary(L"SkinInstaller.dll");
FreeLibrary(msvcrDll);
}
}
}
return rmDll;
}
/*
** Entry point. In Release builds, the entry point is Main() since the CRT is not used.
**
*/
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{
// Prevent system error message boxes.
UINT oldMode = SetErrorMode(0);
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS);
WCHAR* args = GetCommandLineArguments();
HINSTANCE skinInstallerDll = LoadSkinInstallerLibrary();
if (skinInstallerDll)
{
auto skinInstallerMain =
(SkinInstallerMainFunc)GetProcAddress(skinInstallerDll, MAKEINTRESOURCEA(1));
if (skinInstallerMain)
{
return skinInstallerMain(args);
}
}
WCHAR message[128];
wsprintf(
message,
L"SkinInstaller.dll load error %ld.",
GetLastError());
MessageBox(nullptr, message, L"Skin Installer", MB_OK | MB_ICONERROR);
return 1;
}
#ifndef _DEBUG
EXTERN_C int WINAPI Main()
{
int result = wWinMain(nullptr, nullptr, nullptr, 0);
ExitProcess(result);
return 0; // Never reached.
}
#endif
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <Windows.h>
#include <Shlwapi.h>
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
typedef int (*SkinInstallerMainFunc)(LPWSTR cmdLine);
WCHAR* GetCommandLineArguments()
{
WCHAR* args = GetCommandLine();
// Skip past (quoted) application path in cmdLine.
if (*args == L'"')
{
++args; // Skip leading quote.
while (*args && *args != L'"')
{
++args;
}
++args; // Skip trailing quote.
}
else
{
while (*args && *args != L' ')
{
++args;
}
}
// Skip leading whitespace (similar to CRT implementation).
while (*args && *args <= L' ')
{
++args;
}
return args;
}
/*
** Attempts to load SkinInstaller.dll. If it fails, retries after loading our own copies of the
** CRT DLLs in the Runtime directory.
*/
HINSTANCE LoadSkinInstallerLibrary()
{
HINSTANCE rmDll = LoadLibrary(L"SkinInstaller.dll");
if (!rmDll)
{
WCHAR path[MAX_PATH];
if (GetModuleFileName(nullptr, path, MAX_PATH) > 0)
{
PathRemoveFileSpec(path);
PathAppend(path, L"Runtime");
SetDllDirectory(path);
PathAppend(path, L"msvcp120.dll");
// Loading msvcpNNN.dll will load msvcrNNN.dll as well.
HINSTANCE msvcrDll = LoadLibrary(path);
SetDllDirectory(L"");
if (msvcrDll)
{
rmDll = LoadLibrary(L"SkinInstaller.dll");
FreeLibrary(msvcrDll);
}
}
}
return rmDll;
}
/*
** Entry point. In Release builds, the entry point is Main() since the CRT is not used.
**
*/
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{
// Prevent system error message boxes.
UINT oldMode = SetErrorMode(0);
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS);
WCHAR* args = GetCommandLineArguments();
HINSTANCE skinInstallerDll = LoadSkinInstallerLibrary();
if (skinInstallerDll)
{
auto skinInstallerMain =
(SkinInstallerMainFunc)GetProcAddress(skinInstallerDll, MAKEINTRESOURCEA(1));
if (skinInstallerMain)
{
return skinInstallerMain(args);
}
}
WCHAR message[128];
wsprintf(
message,
L"SkinInstaller.dll load error %ld.",
GetLastError());
MessageBox(nullptr, message, L"Skin Installer", MB_OK | MB_ICONERROR);
return 1;
}
#ifndef _DEBUG
EXTERN_C int WINAPI Main()
{
int result = wWinMain(nullptr, nullptr, nullptr, 0);
ExitProcess(result);
return 0; // Never reached.
}
#endif

View File

@ -1,55 +1,55 @@
#include <Windows.h>
#include "resource.h"
#include "../Version.h"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILEVER
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileDescription", "Rainmeter Skin Installer"
VALUE "FileVersion", STRFILEVER
VALUE "LegalCopyright", "<22> 2013 - All authors"
VALUE "OriginalFilename", "SkinInstaller.exe"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
#else
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
#endif //_WIN64
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SKININSTALLER ICON DISCARDABLE "res/Rainstaller.ico"
#include <Windows.h>
#include "resource.h"
#include "../Version.h"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILEVER
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileDescription", "Rainmeter Skin Installer"
VALUE "FileVersion", STRFILEVER
VALUE "LegalCopyright", "<22> 2013 - All authors"
VALUE "OriginalFilename", "SkinInstaller.exe"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
#else
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
#endif //_WIN64
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SKININSTALLER ICON DISCARDABLE "res/Rainstaller.ico"

View File

@ -1,50 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{2D8F1DDB-6470-45A1-B95A-3E2960641314}</ProjectGuid>
<ConfigurationType>Application</ConfigurationType>
<TargetName>SkinInstaller</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<DisableSpecificWarnings>4018;4090;4114;4267;4351;4786;4800;4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>wWinMainCRTStartup</EntryPointSymbol>
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Manifest>
<AdditionalManifestFiles>..\Application\Application.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<EntryPointSymbol>Main</EntryPointSymbol>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="SkinInstallerLauncher.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstallerLauncher.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{2D8F1DDB-6470-45A1-B95A-3E2960641314}</ProjectGuid>
<ConfigurationType>Application</ConfigurationType>
<TargetName>SkinInstaller</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<DisableSpecificWarnings>4018;4090;4114;4267;4351;4786;4800;4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>wWinMainCRTStartup</EntryPointSymbol>
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Manifest>
<AdditionalManifestFiles>..\Application\Application.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<EntryPointSymbol>Main</EntryPointSymbol>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="SkinInstallerLauncher.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstallerLauncher.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstallerLauncher.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SkinInstallerLauncher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SkinInstallerLauncher.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SkinInstallerLauncher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,19 +1,19 @@
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "StdAfx.h"
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "StdAfx.h"

View File

@ -1,49 +1,49 @@
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __STDAFX_H__
#define __STDAFX_H__
// WINAPI
#include <Windows.h>
#include <Windowsx.h>
#include <Commdlg.h>
#include <Imagehlp.h>
#include <Lmcons.h>
#include <Shlobj.h>
#include <Shlwapi.h>
#include <Shellapi.h>
#include <Uxtheme.h>
#include <Wininet.h>
// STL
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <cerrno>
#include <cctype>
// RUNTIME
#include <process.h>
#endif
/*
Copyright (C) 2011 Birunthan Mohanathas
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.
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __STDAFX_H__
#define __STDAFX_H__
// WINAPI
#include <Windows.h>
#include <Windowsx.h>
#include <Commdlg.h>
#include <Imagehlp.h>
#include <Lmcons.h>
#include <Shlobj.h>
#include <Shlwapi.h>
#include <Shellapi.h>
#include <Uxtheme.h>
#include <Wininet.h>
// STL
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <cerrno>
#include <cctype>
// RUNTIME
#include <process.h>
#endif

View File

@ -1,73 +1,73 @@
#define IDC_STATIC -1
#define IDI_SKININSTALLER 100
#define IDB_INSTALLHEADER 101
#define IDD_INSTALL_DIALOG 102
#define IDD_INSTALL_TAB 103
#define IDR_INSTALL_MENU 104
#define IDD_PACKAGE_DIALOG 105
#define IDD_PACKAGEINFO_TAB 106
#define IDD_PACKAGEOPTIONS_TAB 107
#define IDD_PACKAGEADVANCED_TAB 108
#define IDD_PACKAGESELECTFOLDER_DIALOG 109
#define IDD_PACKAGESELECTPLUGIN_DIALOG 110
#define IDC_INSTALL_TAB 1000
#define IDC_INSTALL_HEADER_BITMAP 1001
#define IDC_INSTALL_ADVANCED_BUTTON 1002
#define IDC_INSTALL_INSTALL_BUTTON 1003
#define IDC_INSTALLTAB_NAME_TEXT 1000
#define IDC_INSTALLTAB_AUTHOR_TEXT 1001
#define IDC_INSTALLTAB_VERSION_TEXT 1002
#define IDC_INSTALLTAB_COMPONENTS_LIST 1003
#define IDC_INSTALLTAB_THEME_CHECKBOX 1004
#define IDC_INSTALLTAB_INPROGRESS_TEXT 1005
#define IDC_INSTALLTAB_PROGRESS 1006
#define IDC_PACKAGE_TAB 1000
#define IDC_PACKAGE_NEXT_BUTTON 1001
#define IDC_PACKAGE_CREATEPACKAGE_BUTTON 1002
#define IDC_PACKAGEINFO_NAME_EDIT 1000
#define IDC_PACKAGEINFO_AUTHOR_EDIT 1001
#define IDC_PACKAGEINFO_VERSION_EDIT 1002
#define IDC_PACKAGEINFO_COMPONENTS_LIST 1003
#define IDC_PACKAGEINFO_ADDSKIN_BUTTON 1004
#define IDC_PACKAGEINFO_ADDTHEME_BUTTON 1005
#define IDC_PACKAGEINFO_ADDPLUGIN_BUTTON 1006
#define IDC_PACKAGEINFO_REMOVE_BUTTON 1007
#define IDC_PACKAGEINFO_WHATIS_LINK 1008
#define IDC_PACKAGEOPTIONS_FILE_EDIT 1000
#define IDC_PACKAGEOPTIONS_FILEBROWSE_BUTTON 1001
#define IDC_PACKAGEOPTIONS_DONOTHING_RADIO 1002
#define IDC_PACKAGEOPTIONS_LOADSKIN_RADIO 1003
#define IDC_PACKAGEOPTIONS_LOADSKIN_EDIT 1004
#define IDC_PACKAGEOPTIONS_LOADSKINBROWSE_BUTTON 1005
#define IDC_PACKAGEOPTIONS_LOADTHEME_RADIO 1006
#define IDC_PACKAGEOPTIONS_LOADTHEME_COMBO 1007
#define IDC_PACKAGEOPTIONS_RAINMETERVERSION_EDIT 1008
#define IDC_PACKAGEOPTIONS_WINDOWSVERSION_COMBO 1009
#define IDC_INSTALLTAB_CREATING_TEXT 1010
#define IDC_INSTALLTAB_CREATING_BAR 1011
#define IDC_PACKAGEADVANCED_HEADER_EDIT 1000
#define IDC_PACKAGEADVANCED_HEADERROWSE_BUTTON 1001
#define IDC_PACKAGEADVANCED_VARIABLEFILES_EDIT 1002
#define IDC_PACKAGEADVANCED_MERGESKINS_CHECK 1003
#define IDC_PACKAGEADVANCED_HELP_LINK 1004
#define IDC_PACKAGESELECTFOLDER_EXISTING_RADIO 1000
#define IDC_PACKAGESELECTFOLDER_EXISTING_COMBO 1001
#define IDC_PACKAGESELECTFOLDER_CUSTOM_RADIO 1002
#define IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT 1003
#define IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON 1004
#define IDC_PACKAGESELECTPLUGIN_32BIT_EDIT 1000
#define IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON 1001
#define IDC_PACKAGESELECTPLUGIN_64BIT_EDIT 1002
#define IDC_PACKAGESELECTPLUGIN_64BITBROWSE_BUTTON 1003
#define IDM_INSTALL_BACKUPSKINS 4200
#define IDM_INSTALL_SYSTEMFONTS 4201
#define IDM_INSTALL_FORMAT 4202
#define IDC_STATIC -1
#define IDI_SKININSTALLER 100
#define IDB_INSTALLHEADER 101
#define IDD_INSTALL_DIALOG 102
#define IDD_INSTALL_TAB 103
#define IDR_INSTALL_MENU 104
#define IDD_PACKAGE_DIALOG 105
#define IDD_PACKAGEINFO_TAB 106
#define IDD_PACKAGEOPTIONS_TAB 107
#define IDD_PACKAGEADVANCED_TAB 108
#define IDD_PACKAGESELECTFOLDER_DIALOG 109
#define IDD_PACKAGESELECTPLUGIN_DIALOG 110
#define IDC_INSTALL_TAB 1000
#define IDC_INSTALL_HEADER_BITMAP 1001
#define IDC_INSTALL_ADVANCED_BUTTON 1002
#define IDC_INSTALL_INSTALL_BUTTON 1003
#define IDC_INSTALLTAB_NAME_TEXT 1000
#define IDC_INSTALLTAB_AUTHOR_TEXT 1001
#define IDC_INSTALLTAB_VERSION_TEXT 1002
#define IDC_INSTALLTAB_COMPONENTS_LIST 1003
#define IDC_INSTALLTAB_THEME_CHECKBOX 1004
#define IDC_INSTALLTAB_INPROGRESS_TEXT 1005
#define IDC_INSTALLTAB_PROGRESS 1006
#define IDC_PACKAGE_TAB 1000
#define IDC_PACKAGE_NEXT_BUTTON 1001
#define IDC_PACKAGE_CREATEPACKAGE_BUTTON 1002
#define IDC_PACKAGEINFO_NAME_EDIT 1000
#define IDC_PACKAGEINFO_AUTHOR_EDIT 1001
#define IDC_PACKAGEINFO_VERSION_EDIT 1002
#define IDC_PACKAGEINFO_COMPONENTS_LIST 1003
#define IDC_PACKAGEINFO_ADDSKIN_BUTTON 1004
#define IDC_PACKAGEINFO_ADDTHEME_BUTTON 1005
#define IDC_PACKAGEINFO_ADDPLUGIN_BUTTON 1006
#define IDC_PACKAGEINFO_REMOVE_BUTTON 1007
#define IDC_PACKAGEINFO_WHATIS_LINK 1008
#define IDC_PACKAGEOPTIONS_FILE_EDIT 1000
#define IDC_PACKAGEOPTIONS_FILEBROWSE_BUTTON 1001
#define IDC_PACKAGEOPTIONS_DONOTHING_RADIO 1002
#define IDC_PACKAGEOPTIONS_LOADSKIN_RADIO 1003
#define IDC_PACKAGEOPTIONS_LOADSKIN_EDIT 1004
#define IDC_PACKAGEOPTIONS_LOADSKINBROWSE_BUTTON 1005
#define IDC_PACKAGEOPTIONS_LOADTHEME_RADIO 1006
#define IDC_PACKAGEOPTIONS_LOADTHEME_COMBO 1007
#define IDC_PACKAGEOPTIONS_RAINMETERVERSION_EDIT 1008
#define IDC_PACKAGEOPTIONS_WINDOWSVERSION_COMBO 1009
#define IDC_INSTALLTAB_CREATING_TEXT 1010
#define IDC_INSTALLTAB_CREATING_BAR 1011
#define IDC_PACKAGEADVANCED_HEADER_EDIT 1000
#define IDC_PACKAGEADVANCED_HEADERROWSE_BUTTON 1001
#define IDC_PACKAGEADVANCED_VARIABLEFILES_EDIT 1002
#define IDC_PACKAGEADVANCED_MERGESKINS_CHECK 1003
#define IDC_PACKAGEADVANCED_HELP_LINK 1004
#define IDC_PACKAGESELECTFOLDER_EXISTING_RADIO 1000
#define IDC_PACKAGESELECTFOLDER_EXISTING_COMBO 1001
#define IDC_PACKAGESELECTFOLDER_CUSTOM_RADIO 1002
#define IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT 1003
#define IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON 1004
#define IDC_PACKAGESELECTPLUGIN_32BIT_EDIT 1000
#define IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON 1001
#define IDC_PACKAGESELECTPLUGIN_64BIT_EDIT 1002
#define IDC_PACKAGESELECTPLUGIN_64BITBROWSE_BUTTON 1003
#define IDM_INSTALL_BACKUPSKINS 4200
#define IDM_INSTALL_SYSTEMFONTS 4201
#define IDM_INSTALL_FORMAT 4202

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,186 +1,186 @@
/* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding
* version for AMD64 on Windows using Microsoft C compiler
*
* Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Copyright (C) 2003 Chris Anderson <christop@charm.net>
* Please use the copyright conditions above.
*
* 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant
*
* inffas8664.c call function inffas8664fnc in inffasx64.asm
* inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
*
* Dec-29-2003 -- I added AMD64 inflate asm support. This version is also
* slightly quicker on x86 systems because, instead of using rep movsb to copy
* data, it uses rep movsw, which moves data in 2-byte chunks instead of single
* bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates
* from http://fedora.linux.duke.edu/fc1_x86_64
* which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with
* 1GB ram. The 64-bit version is about 4% faster than the 32-bit version,
* when decompressing mozilla-source-1.3.tar.gz.
*
* Mar-13-2003 -- Most of this is derived from inffast.S which is derived from
* the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at
* the moment. I have successfully compiled and tested this code with gcc2.96,
* gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S
* compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX
* enabled. I will attempt to merge the MMX code into this version. Newer
* versions of this and inffast.S can be found at
* http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/
*
*/
#include <stdio.h>
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
/* Mark Adler's comments from inffast.c: */
/*
Decode literal, length, and distance codes and write out the resulting
literal and match bytes until either not enough input or output is
available, an end-of-block is encountered, or a data error is encountered.
When large enough input and output buffers are supplied to inflate(), for
example, a 16K input buffer and a 64K output buffer, more than 95% of the
inflate execution time is spent in this routine.
Entry assumptions:
state->mode == LEN
strm->avail_in >= 6
strm->avail_out >= 258
start >= strm->avail_out
state->bits < 8
On return, state->mode is one of:
LEN -- ran out of enough output space or enough available input
TYPE -- reached end of block code, inflate() to interpret next block
BAD -- error in block data
Notes:
- The maximum input bits used by a length/distance pair is 15 bits for the
length code, 5 bits for the length extra, 15 bits for the distance code,
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
Therefore if strm->avail_in >= 6, then there is enough input to avoid
checking for available input while decoding.
- The maximum bytes that a single length/distance pair can output is 258
bytes, which is the maximum length that can be coded. inflate_fast()
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
typedef struct inffast_ar {
/* 64 32 x86 x86_64 */
/* ar offset register */
/* 0 0 */ void *esp; /* esp save */
/* 8 4 */ void *ebp; /* ebp save */
/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */
/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */
/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */
/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */
/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */
/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */
/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */
/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */
/* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */
/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */
/* 92 48 */ unsigned wsize; /* window size */
/* 96 52 */ unsigned write; /* window write index */
/*100 56 */ unsigned lmask; /* r12 mask for lcode */
/*104 60 */ unsigned dmask; /* r13 mask for dcode */
/*108 64 */ unsigned len; /* r14 match length */
/*112 68 */ unsigned dist; /* r15 match distance */
/*116 72 */ unsigned status; /* set when state chng*/
} type_ar;
#ifdef ASMINF
void inflate_fast(strm, start)
z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
type_ar ar;
void inffas8664fnc(struct inffast_ar * par);
#if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64))
#define PAD_AVAIL_IN 6
#define PAD_AVAIL_OUT 258
#else
#define PAD_AVAIL_IN 5
#define PAD_AVAIL_OUT 257
#endif
/* copy state to local variables */
state = (struct inflate_state FAR *)strm->state;
ar.in = strm->next_in;
ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN);
ar.out = strm->next_out;
ar.beg = ar.out - (start - strm->avail_out);
ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT);
ar.wsize = state->wsize;
ar.write = state->wnext;
ar.window = state->window;
ar.hold = state->hold;
ar.bits = state->bits;
ar.lcode = state->lencode;
ar.dcode = state->distcode;
ar.lmask = (1U << state->lenbits) - 1;
ar.dmask = (1U << state->distbits) - 1;
/* decode literals and length/distances until end-of-block or not enough
input data or output space */
/* align in on 1/2 hold size boundary */
while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) {
ar.hold += (unsigned long)*ar.in++ << ar.bits;
ar.bits += 8;
}
inffas8664fnc(&ar);
if (ar.status > 1) {
if (ar.status == 2)
strm->msg = "invalid literal/length code";
else if (ar.status == 3)
strm->msg = "invalid distance code";
else
strm->msg = "invalid distance too far back";
state->mode = BAD;
}
else if ( ar.status == 1 ) {
state->mode = TYPE;
}
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
ar.len = ar.bits >> 3;
ar.in -= ar.len;
ar.bits -= ar.len << 3;
ar.hold &= (1U << ar.bits) - 1;
/* update state and return */
strm->next_in = ar.in;
strm->next_out = ar.out;
strm->avail_in = (unsigned)(ar.in < ar.last ?
PAD_AVAIL_IN + (ar.last - ar.in) :
PAD_AVAIL_IN - (ar.in - ar.last));
strm->avail_out = (unsigned)(ar.out < ar.end ?
PAD_AVAIL_OUT + (ar.end - ar.out) :
PAD_AVAIL_OUT - (ar.out - ar.end));
state->hold = (unsigned long)ar.hold;
state->bits = ar.bits;
return;
}
#endif
/* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding
* version for AMD64 on Windows using Microsoft C compiler
*
* Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Copyright (C) 2003 Chris Anderson <christop@charm.net>
* Please use the copyright conditions above.
*
* 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant
*
* inffas8664.c call function inffas8664fnc in inffasx64.asm
* inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
*
* Dec-29-2003 -- I added AMD64 inflate asm support. This version is also
* slightly quicker on x86 systems because, instead of using rep movsb to copy
* data, it uses rep movsw, which moves data in 2-byte chunks instead of single
* bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates
* from http://fedora.linux.duke.edu/fc1_x86_64
* which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with
* 1GB ram. The 64-bit version is about 4% faster than the 32-bit version,
* when decompressing mozilla-source-1.3.tar.gz.
*
* Mar-13-2003 -- Most of this is derived from inffast.S which is derived from
* the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at
* the moment. I have successfully compiled and tested this code with gcc2.96,
* gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S
* compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX
* enabled. I will attempt to merge the MMX code into this version. Newer
* versions of this and inffast.S can be found at
* http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/
*
*/
#include <stdio.h>
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
/* Mark Adler's comments from inffast.c: */
/*
Decode literal, length, and distance codes and write out the resulting
literal and match bytes until either not enough input or output is
available, an end-of-block is encountered, or a data error is encountered.
When large enough input and output buffers are supplied to inflate(), for
example, a 16K input buffer and a 64K output buffer, more than 95% of the
inflate execution time is spent in this routine.
Entry assumptions:
state->mode == LEN
strm->avail_in >= 6
strm->avail_out >= 258
start >= strm->avail_out
state->bits < 8
On return, state->mode is one of:
LEN -- ran out of enough output space or enough available input
TYPE -- reached end of block code, inflate() to interpret next block
BAD -- error in block data
Notes:
- The maximum input bits used by a length/distance pair is 15 bits for the
length code, 5 bits for the length extra, 15 bits for the distance code,
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
Therefore if strm->avail_in >= 6, then there is enough input to avoid
checking for available input while decoding.
- The maximum bytes that a single length/distance pair can output is 258
bytes, which is the maximum length that can be coded. inflate_fast()
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
typedef struct inffast_ar {
/* 64 32 x86 x86_64 */
/* ar offset register */
/* 0 0 */ void *esp; /* esp save */
/* 8 4 */ void *ebp; /* ebp save */
/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */
/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */
/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */
/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */
/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */
/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */
/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */
/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */
/* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */
/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */
/* 92 48 */ unsigned wsize; /* window size */
/* 96 52 */ unsigned write; /* window write index */
/*100 56 */ unsigned lmask; /* r12 mask for lcode */
/*104 60 */ unsigned dmask; /* r13 mask for dcode */
/*108 64 */ unsigned len; /* r14 match length */
/*112 68 */ unsigned dist; /* r15 match distance */
/*116 72 */ unsigned status; /* set when state chng*/
} type_ar;
#ifdef ASMINF
void inflate_fast(strm, start)
z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
type_ar ar;
void inffas8664fnc(struct inffast_ar * par);
#if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64))
#define PAD_AVAIL_IN 6
#define PAD_AVAIL_OUT 258
#else
#define PAD_AVAIL_IN 5
#define PAD_AVAIL_OUT 257
#endif
/* copy state to local variables */
state = (struct inflate_state FAR *)strm->state;
ar.in = strm->next_in;
ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN);
ar.out = strm->next_out;
ar.beg = ar.out - (start - strm->avail_out);
ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT);
ar.wsize = state->wsize;
ar.write = state->wnext;
ar.window = state->window;
ar.hold = state->hold;
ar.bits = state->bits;
ar.lcode = state->lencode;
ar.dcode = state->distcode;
ar.lmask = (1U << state->lenbits) - 1;
ar.dmask = (1U << state->distbits) - 1;
/* decode literals and length/distances until end-of-block or not enough
input data or output space */
/* align in on 1/2 hold size boundary */
while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) {
ar.hold += (unsigned long)*ar.in++ << ar.bits;
ar.bits += 8;
}
inffas8664fnc(&ar);
if (ar.status > 1) {
if (ar.status == 2)
strm->msg = "invalid literal/length code";
else if (ar.status == 3)
strm->msg = "invalid distance code";
else
strm->msg = "invalid distance too far back";
state->mode = BAD;
}
else if ( ar.status == 1 ) {
state->mode = TYPE;
}
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
ar.len = ar.bits >> 3;
ar.in -= ar.len;
ar.bits -= ar.len << 3;
ar.hold &= (1U << ar.bits) - 1;
/* update state and return */
strm->next_in = ar.in;
strm->next_out = ar.out;
strm->avail_in = (unsigned)(ar.in < ar.last ?
PAD_AVAIL_IN + (ar.last - ar.in) :
PAD_AVAIL_IN - (ar.in - ar.last));
strm->avail_out = (unsigned)(ar.out < ar.end ?
PAD_AVAIL_OUT + (ar.end - ar.out) :
PAD_AVAIL_OUT - (ar.out - ar.end));
state->hold = (unsigned long)ar.hold;
state->bits = ar.bits;
return;
}
#endif

View File

@ -1,396 +1,396 @@
; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding
; version for AMD64 on Windows using Microsoft C compiler
;
; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
; inffasx64.asm is called by inffas8664.c, which contain more info.
; to compile this file, I use option
; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm
; with Microsoft Macro Assembler (x64) for AMD64
;
; This file compile with Microsoft Macro Assembler (x64) for AMD64
;
; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK
;
; (you can get Windows WDK with ml64 for AMD64 from
; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price)
;
.code
inffas8664fnc PROC
; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
;
; All registers must be preserved across the call, except for
; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch.
mov [rsp-8],rsi
mov [rsp-16],rdi
mov [rsp-24],r12
mov [rsp-32],r13
mov [rsp-40],r14
mov [rsp-48],r15
mov [rsp-56],rbx
mov rax,rcx
mov [rax+8], rbp ; /* save regs rbp and rsp */
mov [rax], rsp
mov rsp, rax ; /* make rsp point to &ar */
mov rsi, [rsp+16] ; /* rsi = in */
mov rdi, [rsp+32] ; /* rdi = out */
mov r9, [rsp+24] ; /* r9 = last */
mov r10, [rsp+48] ; /* r10 = end */
mov rbp, [rsp+64] ; /* rbp = lcode */
mov r11, [rsp+72] ; /* r11 = dcode */
mov rdx, [rsp+80] ; /* rdx = hold */
mov ebx, [rsp+88] ; /* ebx = bits */
mov r12d, [rsp+100] ; /* r12d = lmask */
mov r13d, [rsp+104] ; /* r13d = dmask */
; /* r14d = len */
; /* r15d = dist */
cld
cmp r10, rdi
je L_one_time ; /* if only one decode left */
cmp r9, rsi
jne L_do_loop
L_one_time:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code_one_time
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
jmp L_get_length_code_one_time
ALIGN 4
L_while_test:
cmp r10, rdi
jbe L_break_loop
cmp r9, rsi
jbe L_break_loop
L_do_loop:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_length_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
mov r8, r12 ; /* r8 = lmask */
shr eax, 16 ; /* output this.val char */
stosb
L_get_length_code_one_time:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
L_dolen:
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
shr eax, 16 ; /* output this.val char */
stosb
jmp L_while_test
ALIGN 4
L_test_for_length_base:
mov r14d, eax ; /* len = this */
shr r14d, 16 ; /* len = this.val */
mov cl, al
test al, 16
jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */
and cl, 15 ; /* op &= 15 */
jz L_decode_distance ; /* if (!op) */
L_add_bits_to_len:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r14d, eax ; /* len += hold & mask[op] */
L_decode_distance:
mov r8, r13 ; /* r8 = dmask */
cmp bl, 32
ja L_get_distance_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_distance_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */
L_dodist:
mov r15d, eax ; /* dist = this */
shr r15d, 16 ; /* dist = this.val */
mov cl, ah
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
mov cl, al ; /* cl = this.op */
test al, 16 ; /* if ((op & 16) == 0) */
jz L_test_for_second_level_dist
and cl, 15 ; /* op &= 15 */
jz L_check_dist_one
L_add_bits_to_dist:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax ; /* (1 << op) - 1 */
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r15d, eax ; /* dist += hold & ((1 << op) - 1) */
L_check_window:
mov r8, rsi ; /* save in so from can use it's reg */
mov rax, rdi
sub rax, [rsp+40] ; /* nbytes = out - beg */
cmp eax, r15d
jb L_clip_window ; /* if (dist > nbytes) 4.2% */
mov ecx, r14d ; /* ecx = len */
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
sar ecx, 1
jnc L_copy_two ; /* if len % 2 == 0 */
rep movsw
mov al, [rsi]
mov [rdi], al
inc rdi
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
L_copy_two:
rep movsw
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
ALIGN 4
L_check_dist_one:
cmp r15d, 1 ; /* if dist 1, is a memset */
jne L_check_window
cmp [rsp+40], rdi ; /* if out == beg, outside window */
je L_check_window
mov ecx, r14d ; /* ecx = len */
mov al, [rdi-1]
mov ah, al
sar ecx, 1
jnc L_set_two
mov [rdi], al
inc rdi
L_set_two:
rep stosw
jmp L_while_test
ALIGN 4
L_test_for_second_level_length:
test al, 64
jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r14d ; /* eax += len */
mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/
jmp L_dolen
ALIGN 4
L_test_for_second_level_dist:
test al, 64
jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r15d ; /* eax += dist */
mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/
jmp L_dodist
ALIGN 4
L_clip_window:
mov ecx, eax ; /* ecx = nbytes */
mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */
neg ecx ; /* nbytes = -nbytes */
cmp eax, r15d
jb L_invalid_distance_too_far ; /* if (dist > wsize) */
add ecx, r15d ; /* nbytes = dist - nbytes */
cmp dword ptr [rsp+96], 0
jne L_wrap_around_window ; /* if (write != 0) */
mov rsi, [rsp+56] ; /* from = window */
sub eax, ecx ; /* eax -= nbytes */
add rsi, rax ; /* from += wsize - nbytes */
mov eax, r14d ; /* eax = len */
cmp r14d, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* eax -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = &out[ -dist ] */
jmp L_do_copy
ALIGN 4
L_wrap_around_window:
mov eax, [rsp+96] ; /* eax = write */
cmp ecx, eax
jbe L_contiguous_in_window ; /* if (write >= nbytes) */
mov esi, [rsp+92] ; /* from = wsize */
add rsi, [rsp+56] ; /* from += window */
add rsi, rax ; /* from += write */
sub rsi, rcx ; /* from -= nbytes */
sub ecx, eax ; /* nbytes -= write */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, [rsp+56] ; /* from = window */
mov ecx, [rsp+96] ; /* nbytes = write */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy
ALIGN 4
L_contiguous_in_window:
mov rsi, [rsp+56] ; /* rsi = window */
add rsi, rax
sub rsi, rcx ; /* from += write - nbytes */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy ; /* if (nbytes >= len) */
ALIGN 4
L_do_copy:
mov ecx, eax ; /* ecx = len */
rep movsb
mov rsi, r8 ; /* move in back to %esi, toss from */
jmp L_while_test
L_test_for_end_of_block:
test al, 32
jz L_invalid_literal_length_code
mov dword ptr [rsp+116], 1
jmp L_break_loop_with_status
L_invalid_literal_length_code:
mov dword ptr [rsp+116], 2
jmp L_break_loop_with_status
L_invalid_distance_code:
mov dword ptr [rsp+116], 3
jmp L_break_loop_with_status
L_invalid_distance_too_far:
mov dword ptr [rsp+116], 4
jmp L_break_loop_with_status
L_break_loop:
mov dword ptr [rsp+116], 0
L_break_loop_with_status:
; /* put in, out, bits, and hold back into ar and pop esp */
mov [rsp+16], rsi ; /* in */
mov [rsp+32], rdi ; /* out */
mov [rsp+88], ebx ; /* bits */
mov [rsp+80], rdx ; /* hold */
mov rax, [rsp] ; /* restore rbp and rsp */
mov rbp, [rsp+8]
mov rsp, rax
mov rsi,[rsp-8]
mov rdi,[rsp-16]
mov r12,[rsp-24]
mov r13,[rsp-32]
mov r14,[rsp-40]
mov r15,[rsp-48]
mov rbx,[rsp-56]
ret 0
; :
; : "m" (ar)
; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
; );
inffas8664fnc ENDP
;_TEXT ENDS
END
; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding
; version for AMD64 on Windows using Microsoft C compiler
;
; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
; inffasx64.asm is called by inffas8664.c, which contain more info.
; to compile this file, I use option
; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm
; with Microsoft Macro Assembler (x64) for AMD64
;
; This file compile with Microsoft Macro Assembler (x64) for AMD64
;
; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK
;
; (you can get Windows WDK with ml64 for AMD64 from
; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price)
;
.code
inffas8664fnc PROC
; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
;
; All registers must be preserved across the call, except for
; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch.
mov [rsp-8],rsi
mov [rsp-16],rdi
mov [rsp-24],r12
mov [rsp-32],r13
mov [rsp-40],r14
mov [rsp-48],r15
mov [rsp-56],rbx
mov rax,rcx
mov [rax+8], rbp ; /* save regs rbp and rsp */
mov [rax], rsp
mov rsp, rax ; /* make rsp point to &ar */
mov rsi, [rsp+16] ; /* rsi = in */
mov rdi, [rsp+32] ; /* rdi = out */
mov r9, [rsp+24] ; /* r9 = last */
mov r10, [rsp+48] ; /* r10 = end */
mov rbp, [rsp+64] ; /* rbp = lcode */
mov r11, [rsp+72] ; /* r11 = dcode */
mov rdx, [rsp+80] ; /* rdx = hold */
mov ebx, [rsp+88] ; /* ebx = bits */
mov r12d, [rsp+100] ; /* r12d = lmask */
mov r13d, [rsp+104] ; /* r13d = dmask */
; /* r14d = len */
; /* r15d = dist */
cld
cmp r10, rdi
je L_one_time ; /* if only one decode left */
cmp r9, rsi
jne L_do_loop
L_one_time:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code_one_time
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
jmp L_get_length_code_one_time
ALIGN 4
L_while_test:
cmp r10, rdi
jbe L_break_loop
cmp r9, rsi
jbe L_break_loop
L_do_loop:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_length_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
mov r8, r12 ; /* r8 = lmask */
shr eax, 16 ; /* output this.val char */
stosb
L_get_length_code_one_time:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
L_dolen:
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
shr eax, 16 ; /* output this.val char */
stosb
jmp L_while_test
ALIGN 4
L_test_for_length_base:
mov r14d, eax ; /* len = this */
shr r14d, 16 ; /* len = this.val */
mov cl, al
test al, 16
jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */
and cl, 15 ; /* op &= 15 */
jz L_decode_distance ; /* if (!op) */
L_add_bits_to_len:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r14d, eax ; /* len += hold & mask[op] */
L_decode_distance:
mov r8, r13 ; /* r8 = dmask */
cmp bl, 32
ja L_get_distance_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_distance_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */
L_dodist:
mov r15d, eax ; /* dist = this */
shr r15d, 16 ; /* dist = this.val */
mov cl, ah
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
mov cl, al ; /* cl = this.op */
test al, 16 ; /* if ((op & 16) == 0) */
jz L_test_for_second_level_dist
and cl, 15 ; /* op &= 15 */
jz L_check_dist_one
L_add_bits_to_dist:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax ; /* (1 << op) - 1 */
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r15d, eax ; /* dist += hold & ((1 << op) - 1) */
L_check_window:
mov r8, rsi ; /* save in so from can use it's reg */
mov rax, rdi
sub rax, [rsp+40] ; /* nbytes = out - beg */
cmp eax, r15d
jb L_clip_window ; /* if (dist > nbytes) 4.2% */
mov ecx, r14d ; /* ecx = len */
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
sar ecx, 1
jnc L_copy_two ; /* if len % 2 == 0 */
rep movsw
mov al, [rsi]
mov [rdi], al
inc rdi
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
L_copy_two:
rep movsw
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
ALIGN 4
L_check_dist_one:
cmp r15d, 1 ; /* if dist 1, is a memset */
jne L_check_window
cmp [rsp+40], rdi ; /* if out == beg, outside window */
je L_check_window
mov ecx, r14d ; /* ecx = len */
mov al, [rdi-1]
mov ah, al
sar ecx, 1
jnc L_set_two
mov [rdi], al
inc rdi
L_set_two:
rep stosw
jmp L_while_test
ALIGN 4
L_test_for_second_level_length:
test al, 64
jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r14d ; /* eax += len */
mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/
jmp L_dolen
ALIGN 4
L_test_for_second_level_dist:
test al, 64
jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r15d ; /* eax += dist */
mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/
jmp L_dodist
ALIGN 4
L_clip_window:
mov ecx, eax ; /* ecx = nbytes */
mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */
neg ecx ; /* nbytes = -nbytes */
cmp eax, r15d
jb L_invalid_distance_too_far ; /* if (dist > wsize) */
add ecx, r15d ; /* nbytes = dist - nbytes */
cmp dword ptr [rsp+96], 0
jne L_wrap_around_window ; /* if (write != 0) */
mov rsi, [rsp+56] ; /* from = window */
sub eax, ecx ; /* eax -= nbytes */
add rsi, rax ; /* from += wsize - nbytes */
mov eax, r14d ; /* eax = len */
cmp r14d, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* eax -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = &out[ -dist ] */
jmp L_do_copy
ALIGN 4
L_wrap_around_window:
mov eax, [rsp+96] ; /* eax = write */
cmp ecx, eax
jbe L_contiguous_in_window ; /* if (write >= nbytes) */
mov esi, [rsp+92] ; /* from = wsize */
add rsi, [rsp+56] ; /* from += window */
add rsi, rax ; /* from += write */
sub rsi, rcx ; /* from -= nbytes */
sub ecx, eax ; /* nbytes -= write */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, [rsp+56] ; /* from = window */
mov ecx, [rsp+96] ; /* nbytes = write */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy
ALIGN 4
L_contiguous_in_window:
mov rsi, [rsp+56] ; /* rsi = window */
add rsi, rax
sub rsi, rcx ; /* from += write - nbytes */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy ; /* if (nbytes >= len) */
ALIGN 4
L_do_copy:
mov ecx, eax ; /* ecx = len */
rep movsb
mov rsi, r8 ; /* move in back to %esi, toss from */
jmp L_while_test
L_test_for_end_of_block:
test al, 32
jz L_invalid_literal_length_code
mov dword ptr [rsp+116], 1
jmp L_break_loop_with_status
L_invalid_literal_length_code:
mov dword ptr [rsp+116], 2
jmp L_break_loop_with_status
L_invalid_distance_code:
mov dword ptr [rsp+116], 3
jmp L_break_loop_with_status
L_invalid_distance_too_far:
mov dword ptr [rsp+116], 4
jmp L_break_loop_with_status
L_break_loop:
mov dword ptr [rsp+116], 0
L_break_loop_with_status:
; /* put in, out, bits, and hold back into ar and pop esp */
mov [rsp+16], rsi ; /* in */
mov [rsp+32], rdi ; /* out */
mov [rsp+88], ebx ; /* bits */
mov [rsp+80], rdx ; /* hold */
mov rax, [rsp] ; /* restore rbp and rsp */
mov rbp, [rsp+8]
mov rsp, rax
mov rsi,[rsp-8]
mov rdi,[rsp-16]
mov r12,[rsp-24]
mov r13,[rsp-32]
mov r14,[rsp-40]
mov r15,[rsp-48]
mov rbx,[rsp-56]
ret 0
; :
; : "m" (ar)
; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
; );
inffas8664fnc ENDP
;_TEXT ENDS
END

View File

@ -1,479 +1,479 @@
; match686.asm -- Asm portion of the optimized longest_match for 32 bits x86
; Copyright (C) 1995-1996 Jean-loup Gailly, Brian Raiter and Gilles Vollant.
; File written by Gilles Vollant, by converting match686.S from Brian Raiter
; for MASM. This is as assembly version of longest_match
; from Jean-loup Gailly in deflate.c
;
; http://www.zlib.net
; http://www.winimage.com/zLibDll
; http://www.muppetlabs.com/~breadbox/software/assembly.html
;
; For Visual C++ 4.x and higher and ML 6.x and higher
; ml.exe is distributed in
; http://www.microsoft.com/downloads/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64
;
; this file contain two implementation of longest_match
;
; this longest_match was written by Brian raiter (1998), optimized for Pentium Pro
; (and the faster known version of match_init on modern Core 2 Duo and AMD Phenom)
;
; for using an assembly version of longest_match, you need define ASMV in project
;
; compile the asm file running
; ml /coff /Zi /c /Flmatch686.lst match686.asm
; and do not include match686.obj in your project
;
; note: contrib of zLib 1.2.3 and earlier contained both a deprecated version for
; Pentium (prior Pentium Pro) and this version for Pentium Pro and modern processor
; with autoselect (with cpu detection code)
; if you want support the old pentium optimization, you can still use these version
;
; this file is not optimized for old pentium, but it compatible with all x86 32 bits
; processor (starting 80386)
;
;
; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2
;uInt longest_match(s, cur_match)
; deflate_state *s;
; IPos cur_match; /* current match */
NbStack equ 76
cur_match equ dword ptr[esp+NbStack-0]
str_s equ dword ptr[esp+NbStack-4]
; 5 dword on top (ret,ebp,esi,edi,ebx)
adrret equ dword ptr[esp+NbStack-8]
pushebp equ dword ptr[esp+NbStack-12]
pushedi equ dword ptr[esp+NbStack-16]
pushesi equ dword ptr[esp+NbStack-20]
pushebx equ dword ptr[esp+NbStack-24]
chain_length equ dword ptr [esp+NbStack-28]
limit equ dword ptr [esp+NbStack-32]
best_len equ dword ptr [esp+NbStack-36]
window equ dword ptr [esp+NbStack-40]
prev equ dword ptr [esp+NbStack-44]
scan_start equ word ptr [esp+NbStack-48]
wmask equ dword ptr [esp+NbStack-52]
match_start_ptr equ dword ptr [esp+NbStack-56]
nice_match equ dword ptr [esp+NbStack-60]
scan equ dword ptr [esp+NbStack-64]
windowlen equ dword ptr [esp+NbStack-68]
match_start equ dword ptr [esp+NbStack-72]
strend equ dword ptr [esp+NbStack-76]
NbStackAdd equ (NbStack-24)
.386p
name gvmatch
.MODEL FLAT
; all the +zlib1222add offsets are due to the addition of fields
; in zlib in the deflate_state structure since the asm code was first written
; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
zlib1222add equ 8
; Note : these value are good with a 8 bytes boundary pack structure
dep_chain_length equ 74h+zlib1222add
dep_window equ 30h+zlib1222add
dep_strstart equ 64h+zlib1222add
dep_prev_length equ 70h+zlib1222add
dep_nice_match equ 88h+zlib1222add
dep_w_size equ 24h+zlib1222add
dep_prev equ 38h+zlib1222add
dep_w_mask equ 2ch+zlib1222add
dep_good_match equ 84h+zlib1222add
dep_match_start equ 68h+zlib1222add
dep_lookahead equ 6ch+zlib1222add
_TEXT segment
IFDEF NOUNDERLINE
public longest_match
public match_init
ELSE
public _longest_match
public _match_init
ENDIF
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
;;; stack frame offsets
chainlenwmask equ esp + 0 ; high word: current chain len
; low word: s->wmask
window equ esp + 4 ; local copy of s->window
windowbestlen equ esp + 8 ; s->window + bestlen
scanstart equ esp + 16 ; first two bytes of string
scanend equ esp + 12 ; last two bytes of string
scanalign equ esp + 20 ; dword-misalignment of string
nicematch equ esp + 24 ; a good enough match size
bestlen equ esp + 28 ; size of best match so far
scan equ esp + 32 ; ptr to string wanting match
LocalVarsSize equ 36
; saved ebx byte esp + 36
; saved edi byte esp + 40
; saved esi byte esp + 44
; saved ebp byte esp + 48
; return address byte esp + 52
deflatestate equ esp + 56 ; the function arguments
curmatch equ esp + 60
;;; Offsets for fields in the deflate_state structure. These numbers
;;; are calculated from the definition of deflate_state, with the
;;; assumption that the compiler will dword-align the fields. (Thus,
;;; changing the definition of deflate_state could easily cause this
;;; program to crash horribly, without so much as a warning at
;;; compile time. Sigh.)
dsWSize equ 36+zlib1222add
dsWMask equ 44+zlib1222add
dsWindow equ 48+zlib1222add
dsPrev equ 56+zlib1222add
dsMatchLen equ 88+zlib1222add
dsPrevMatch equ 92+zlib1222add
dsStrStart equ 100+zlib1222add
dsMatchStart equ 104+zlib1222add
dsLookahead equ 108+zlib1222add
dsPrevLen equ 112+zlib1222add
dsMaxChainLen equ 116+zlib1222add
dsGoodMatch equ 132+zlib1222add
dsNiceMatch equ 136+zlib1222add
;;; match686.asm -- Pentium-Pro-optimized version of longest_match()
;;; Written for zlib 1.1.2
;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html
;;;
;;
;; This software is provided 'as-is', without any express or implied
;; warranty. In no event will the authors be held liable for any damages
;; arising from the use of this software.
;;
;; Permission is granted to anyone to use this software for any purpose,
;; including commercial applications, and to alter it and redistribute it
;; freely, subject to the following restrictions:
;;
;; 1. The origin of this software must not be misrepresented; you must not
;; claim that you wrote the original software. If you use this software
;; in a product, an acknowledgment in the product documentation would be
;; appreciated but is not required.
;; 2. Altered source versions must be plainly marked as such, and must not be
;; misrepresented as being the original software
;; 3. This notice may not be removed or altered from any source distribution.
;;
;GLOBAL _longest_match, _match_init
;SECTION .text
;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
;_longest_match:
IFDEF NOUNDERLINE
longest_match proc near
ELSE
_longest_match proc near
ENDIF
.FPO (9, 4, 0, 0, 1, 0)
;;; Save registers that the compiler may be using, and adjust esp to
;;; make room for our stack frame.
push ebp
push edi
push esi
push ebx
sub esp, LocalVarsSize
;;; Retrieve the function arguments. ecx will hold cur_match
;;; throughout the entire function. edx will hold the pointer to the
;;; deflate_state structure during the function's setup (before
;;; entering the main loop.
mov edx, [deflatestate]
mov ecx, [curmatch]
;;; uInt wmask = s->w_mask;
;;; unsigned chain_length = s->max_chain_length;
;;; if (s->prev_length >= s->good_match) {
;;; chain_length >>= 2;
;;; }
mov eax, [edx + dsPrevLen]
mov ebx, [edx + dsGoodMatch]
cmp eax, ebx
mov eax, [edx + dsWMask]
mov ebx, [edx + dsMaxChainLen]
jl LastMatchGood
shr ebx, 2
LastMatchGood:
;;; chainlen is decremented once beforehand so that the function can
;;; use the sign flag instead of the zero flag for the exit test.
;;; It is then shifted into the high word, to make room for the wmask
;;; value, which it will always accompany.
dec ebx
shl ebx, 16
or ebx, eax
mov [chainlenwmask], ebx
;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
mov eax, [edx + dsNiceMatch]
mov ebx, [edx + dsLookahead]
cmp ebx, eax
jl LookaheadLess
mov ebx, eax
LookaheadLess: mov [nicematch], ebx
;;; register Bytef *scan = s->window + s->strstart;
mov esi, [edx + dsWindow]
mov [window], esi
mov ebp, [edx + dsStrStart]
lea edi, [esi + ebp]
mov [scan], edi
;;; Determine how many bytes the scan ptr is off from being
;;; dword-aligned.
mov eax, edi
neg eax
and eax, 3
mov [scanalign], eax
;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
mov eax, [edx + dsWSize]
sub eax, MIN_LOOKAHEAD
sub ebp, eax
jg LimitPositive
xor ebp, ebp
LimitPositive:
;;; int best_len = s->prev_length;
mov eax, [edx + dsPrevLen]
mov [bestlen], eax
;;; Store the sum of s->window + best_len in esi locally, and in esi.
add esi, eax
mov [windowbestlen], esi
;;; register ush scan_start = *(ushf*)scan;
;;; register ush scan_end = *(ushf*)(scan+best_len-1);
;;; Posf *prev = s->prev;
movzx ebx, word ptr [edi]
mov [scanstart], ebx
movzx ebx, word ptr [edi + eax - 1]
mov [scanend], ebx
mov edi, [edx + dsPrev]
;;; Jump into the main loop.
mov edx, [chainlenwmask]
jmp short LoopEntry
align 4
;;; do {
;;; match = s->window + cur_match;
;;; if (*(ushf*)(match+best_len-1) != scan_end ||
;;; *(ushf*)match != scan_start) continue;
;;; [...]
;;; } while ((cur_match = prev[cur_match & wmask]) > limit
;;; && --chain_length != 0);
;;;
;;; Here is the inner loop of the function. The function will spend the
;;; majority of its time in this loop, and majority of that time will
;;; be spent in the first ten instructions.
;;;
;;; Within this loop:
;;; ebx = scanend
;;; ecx = curmatch
;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
;;; esi = windowbestlen - i.e., (window + bestlen)
;;; edi = prev
;;; ebp = limit
LookupLoop:
and ecx, edx
movzx ecx, word ptr [edi + ecx*2]
cmp ecx, ebp
jbe LeaveNow
sub edx, 00010000h
js LeaveNow
LoopEntry: movzx eax, word ptr [esi + ecx - 1]
cmp eax, ebx
jnz LookupLoop
mov eax, [window]
movzx eax, word ptr [eax + ecx]
cmp eax, [scanstart]
jnz LookupLoop
;;; Store the current value of chainlen.
mov [chainlenwmask], edx
;;; Point edi to the string under scrutiny, and esi to the string we
;;; are hoping to match it up with. In actuality, esi and edi are
;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
;;; initialized to -(MAX_MATCH_8 - scanalign).
mov esi, [window]
mov edi, [scan]
add esi, ecx
mov eax, [scanalign]
mov edx, 0fffffef8h; -(MAX_MATCH_8)
lea edi, [edi + eax + 0108h] ;MAX_MATCH_8]
lea esi, [esi + eax + 0108h] ;MAX_MATCH_8]
;;; Test the strings for equality, 8 bytes at a time. At the end,
;;; adjust edx so that it is offset to the exact byte that mismatched.
;;;
;;; We already know at this point that the first three bytes of the
;;; strings match each other, and they can be safely passed over before
;;; starting the compare loop. So what this code does is skip over 0-3
;;; bytes, as much as necessary in order to dword-align the edi
;;; pointer. (esi will still be misaligned three times out of four.)
;;;
;;; It should be confessed that this loop usually does not represent
;;; much of the total running time. Replacing it with a more
;;; straightforward "rep cmpsb" would not drastically degrade
;;; performance.
LoopCmps:
mov eax, [esi + edx]
xor eax, [edi + edx]
jnz LeaveLoopCmps
mov eax, [esi + edx + 4]
xor eax, [edi + edx + 4]
jnz LeaveLoopCmps4
add edx, 8
jnz LoopCmps
jmp short LenMaximum
LeaveLoopCmps4: add edx, 4
LeaveLoopCmps: test eax, 0000FFFFh
jnz LenLower
add edx, 2
shr eax, 16
LenLower: sub al, 1
adc edx, 0
;;; Calculate the length of the match. If it is longer than MAX_MATCH,
;;; then automatically accept it as the best possible match and leave.
lea eax, [edi + edx]
mov edi, [scan]
sub eax, edi
cmp eax, MAX_MATCH
jge LenMaximum
;;; If the length of the match is not longer than the best match we
;;; have so far, then forget it and return to the lookup loop.
mov edx, [deflatestate]
mov ebx, [bestlen]
cmp eax, ebx
jg LongerMatch
mov esi, [windowbestlen]
mov edi, [edx + dsPrev]
mov ebx, [scanend]
mov edx, [chainlenwmask]
jmp LookupLoop
;;; s->match_start = cur_match;
;;; best_len = len;
;;; if (len >= nice_match) break;
;;; scan_end = *(ushf*)(scan+best_len-1);
LongerMatch: mov ebx, [nicematch]
mov [bestlen], eax
mov [edx + dsMatchStart], ecx
cmp eax, ebx
jge LeaveNow
mov esi, [window]
add esi, eax
mov [windowbestlen], esi
movzx ebx, word ptr [edi + eax - 1]
mov edi, [edx + dsPrev]
mov [scanend], ebx
mov edx, [chainlenwmask]
jmp LookupLoop
;;; Accept the current string, with the maximum possible length.
LenMaximum: mov edx, [deflatestate]
mov dword ptr [bestlen], MAX_MATCH
mov [edx + dsMatchStart], ecx
;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
;;; return s->lookahead;
LeaveNow:
mov edx, [deflatestate]
mov ebx, [bestlen]
mov eax, [edx + dsLookahead]
cmp ebx, eax
jg LookaheadRet
mov eax, ebx
LookaheadRet:
;;; Restore the stack and return from whence we came.
add esp, LocalVarsSize
pop ebx
pop esi
pop edi
pop ebp
ret
; please don't remove this string !
; Your can freely use match686 in any free or commercial app if you don't remove the string in the binary!
db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
IFDEF NOUNDERLINE
longest_match endp
ELSE
_longest_match endp
ENDIF
IFDEF NOUNDERLINE
match_init proc near
ret
match_init endp
ELSE
_match_init proc near
ret
_match_init endp
ENDIF
_TEXT ends
end
; match686.asm -- Asm portion of the optimized longest_match for 32 bits x86
; Copyright (C) 1995-1996 Jean-loup Gailly, Brian Raiter and Gilles Vollant.
; File written by Gilles Vollant, by converting match686.S from Brian Raiter
; for MASM. This is as assembly version of longest_match
; from Jean-loup Gailly in deflate.c
;
; http://www.zlib.net
; http://www.winimage.com/zLibDll
; http://www.muppetlabs.com/~breadbox/software/assembly.html
;
; For Visual C++ 4.x and higher and ML 6.x and higher
; ml.exe is distributed in
; http://www.microsoft.com/downloads/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64
;
; this file contain two implementation of longest_match
;
; this longest_match was written by Brian raiter (1998), optimized for Pentium Pro
; (and the faster known version of match_init on modern Core 2 Duo and AMD Phenom)
;
; for using an assembly version of longest_match, you need define ASMV in project
;
; compile the asm file running
; ml /coff /Zi /c /Flmatch686.lst match686.asm
; and do not include match686.obj in your project
;
; note: contrib of zLib 1.2.3 and earlier contained both a deprecated version for
; Pentium (prior Pentium Pro) and this version for Pentium Pro and modern processor
; with autoselect (with cpu detection code)
; if you want support the old pentium optimization, you can still use these version
;
; this file is not optimized for old pentium, but it compatible with all x86 32 bits
; processor (starting 80386)
;
;
; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2
;uInt longest_match(s, cur_match)
; deflate_state *s;
; IPos cur_match; /* current match */
NbStack equ 76
cur_match equ dword ptr[esp+NbStack-0]
str_s equ dword ptr[esp+NbStack-4]
; 5 dword on top (ret,ebp,esi,edi,ebx)
adrret equ dword ptr[esp+NbStack-8]
pushebp equ dword ptr[esp+NbStack-12]
pushedi equ dword ptr[esp+NbStack-16]
pushesi equ dword ptr[esp+NbStack-20]
pushebx equ dword ptr[esp+NbStack-24]
chain_length equ dword ptr [esp+NbStack-28]
limit equ dword ptr [esp+NbStack-32]
best_len equ dword ptr [esp+NbStack-36]
window equ dword ptr [esp+NbStack-40]
prev equ dword ptr [esp+NbStack-44]
scan_start equ word ptr [esp+NbStack-48]
wmask equ dword ptr [esp+NbStack-52]
match_start_ptr equ dword ptr [esp+NbStack-56]
nice_match equ dword ptr [esp+NbStack-60]
scan equ dword ptr [esp+NbStack-64]
windowlen equ dword ptr [esp+NbStack-68]
match_start equ dword ptr [esp+NbStack-72]
strend equ dword ptr [esp+NbStack-76]
NbStackAdd equ (NbStack-24)
.386p
name gvmatch
.MODEL FLAT
; all the +zlib1222add offsets are due to the addition of fields
; in zlib in the deflate_state structure since the asm code was first written
; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
zlib1222add equ 8
; Note : these value are good with a 8 bytes boundary pack structure
dep_chain_length equ 74h+zlib1222add
dep_window equ 30h+zlib1222add
dep_strstart equ 64h+zlib1222add
dep_prev_length equ 70h+zlib1222add
dep_nice_match equ 88h+zlib1222add
dep_w_size equ 24h+zlib1222add
dep_prev equ 38h+zlib1222add
dep_w_mask equ 2ch+zlib1222add
dep_good_match equ 84h+zlib1222add
dep_match_start equ 68h+zlib1222add
dep_lookahead equ 6ch+zlib1222add
_TEXT segment
IFDEF NOUNDERLINE
public longest_match
public match_init
ELSE
public _longest_match
public _match_init
ENDIF
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
;;; stack frame offsets
chainlenwmask equ esp + 0 ; high word: current chain len
; low word: s->wmask
window equ esp + 4 ; local copy of s->window
windowbestlen equ esp + 8 ; s->window + bestlen
scanstart equ esp + 16 ; first two bytes of string
scanend equ esp + 12 ; last two bytes of string
scanalign equ esp + 20 ; dword-misalignment of string
nicematch equ esp + 24 ; a good enough match size
bestlen equ esp + 28 ; size of best match so far
scan equ esp + 32 ; ptr to string wanting match
LocalVarsSize equ 36
; saved ebx byte esp + 36
; saved edi byte esp + 40
; saved esi byte esp + 44
; saved ebp byte esp + 48
; return address byte esp + 52
deflatestate equ esp + 56 ; the function arguments
curmatch equ esp + 60
;;; Offsets for fields in the deflate_state structure. These numbers
;;; are calculated from the definition of deflate_state, with the
;;; assumption that the compiler will dword-align the fields. (Thus,
;;; changing the definition of deflate_state could easily cause this
;;; program to crash horribly, without so much as a warning at
;;; compile time. Sigh.)
dsWSize equ 36+zlib1222add
dsWMask equ 44+zlib1222add
dsWindow equ 48+zlib1222add
dsPrev equ 56+zlib1222add
dsMatchLen equ 88+zlib1222add
dsPrevMatch equ 92+zlib1222add
dsStrStart equ 100+zlib1222add
dsMatchStart equ 104+zlib1222add
dsLookahead equ 108+zlib1222add
dsPrevLen equ 112+zlib1222add
dsMaxChainLen equ 116+zlib1222add
dsGoodMatch equ 132+zlib1222add
dsNiceMatch equ 136+zlib1222add
;;; match686.asm -- Pentium-Pro-optimized version of longest_match()
;;; Written for zlib 1.1.2
;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html
;;;
;;
;; This software is provided 'as-is', without any express or implied
;; warranty. In no event will the authors be held liable for any damages
;; arising from the use of this software.
;;
;; Permission is granted to anyone to use this software for any purpose,
;; including commercial applications, and to alter it and redistribute it
;; freely, subject to the following restrictions:
;;
;; 1. The origin of this software must not be misrepresented; you must not
;; claim that you wrote the original software. If you use this software
;; in a product, an acknowledgment in the product documentation would be
;; appreciated but is not required.
;; 2. Altered source versions must be plainly marked as such, and must not be
;; misrepresented as being the original software
;; 3. This notice may not be removed or altered from any source distribution.
;;
;GLOBAL _longest_match, _match_init
;SECTION .text
;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
;_longest_match:
IFDEF NOUNDERLINE
longest_match proc near
ELSE
_longest_match proc near
ENDIF
.FPO (9, 4, 0, 0, 1, 0)
;;; Save registers that the compiler may be using, and adjust esp to
;;; make room for our stack frame.
push ebp
push edi
push esi
push ebx
sub esp, LocalVarsSize
;;; Retrieve the function arguments. ecx will hold cur_match
;;; throughout the entire function. edx will hold the pointer to the
;;; deflate_state structure during the function's setup (before
;;; entering the main loop.
mov edx, [deflatestate]
mov ecx, [curmatch]
;;; uInt wmask = s->w_mask;
;;; unsigned chain_length = s->max_chain_length;
;;; if (s->prev_length >= s->good_match) {
;;; chain_length >>= 2;
;;; }
mov eax, [edx + dsPrevLen]
mov ebx, [edx + dsGoodMatch]
cmp eax, ebx
mov eax, [edx + dsWMask]
mov ebx, [edx + dsMaxChainLen]
jl LastMatchGood
shr ebx, 2
LastMatchGood:
;;; chainlen is decremented once beforehand so that the function can
;;; use the sign flag instead of the zero flag for the exit test.
;;; It is then shifted into the high word, to make room for the wmask
;;; value, which it will always accompany.
dec ebx
shl ebx, 16
or ebx, eax
mov [chainlenwmask], ebx
;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
mov eax, [edx + dsNiceMatch]
mov ebx, [edx + dsLookahead]
cmp ebx, eax
jl LookaheadLess
mov ebx, eax
LookaheadLess: mov [nicematch], ebx
;;; register Bytef *scan = s->window + s->strstart;
mov esi, [edx + dsWindow]
mov [window], esi
mov ebp, [edx + dsStrStart]
lea edi, [esi + ebp]
mov [scan], edi
;;; Determine how many bytes the scan ptr is off from being
;;; dword-aligned.
mov eax, edi
neg eax
and eax, 3
mov [scanalign], eax
;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
mov eax, [edx + dsWSize]
sub eax, MIN_LOOKAHEAD
sub ebp, eax
jg LimitPositive
xor ebp, ebp
LimitPositive:
;;; int best_len = s->prev_length;
mov eax, [edx + dsPrevLen]
mov [bestlen], eax
;;; Store the sum of s->window + best_len in esi locally, and in esi.
add esi, eax
mov [windowbestlen], esi
;;; register ush scan_start = *(ushf*)scan;
;;; register ush scan_end = *(ushf*)(scan+best_len-1);
;;; Posf *prev = s->prev;
movzx ebx, word ptr [edi]
mov [scanstart], ebx
movzx ebx, word ptr [edi + eax - 1]
mov [scanend], ebx
mov edi, [edx + dsPrev]
;;; Jump into the main loop.
mov edx, [chainlenwmask]
jmp short LoopEntry
align 4
;;; do {
;;; match = s->window + cur_match;
;;; if (*(ushf*)(match+best_len-1) != scan_end ||
;;; *(ushf*)match != scan_start) continue;
;;; [...]
;;; } while ((cur_match = prev[cur_match & wmask]) > limit
;;; && --chain_length != 0);
;;;
;;; Here is the inner loop of the function. The function will spend the
;;; majority of its time in this loop, and majority of that time will
;;; be spent in the first ten instructions.
;;;
;;; Within this loop:
;;; ebx = scanend
;;; ecx = curmatch
;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
;;; esi = windowbestlen - i.e., (window + bestlen)
;;; edi = prev
;;; ebp = limit
LookupLoop:
and ecx, edx
movzx ecx, word ptr [edi + ecx*2]
cmp ecx, ebp
jbe LeaveNow
sub edx, 00010000h
js LeaveNow
LoopEntry: movzx eax, word ptr [esi + ecx - 1]
cmp eax, ebx
jnz LookupLoop
mov eax, [window]
movzx eax, word ptr [eax + ecx]
cmp eax, [scanstart]
jnz LookupLoop
;;; Store the current value of chainlen.
mov [chainlenwmask], edx
;;; Point edi to the string under scrutiny, and esi to the string we
;;; are hoping to match it up with. In actuality, esi and edi are
;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
;;; initialized to -(MAX_MATCH_8 - scanalign).
mov esi, [window]
mov edi, [scan]
add esi, ecx
mov eax, [scanalign]
mov edx, 0fffffef8h; -(MAX_MATCH_8)
lea edi, [edi + eax + 0108h] ;MAX_MATCH_8]
lea esi, [esi + eax + 0108h] ;MAX_MATCH_8]
;;; Test the strings for equality, 8 bytes at a time. At the end,
;;; adjust edx so that it is offset to the exact byte that mismatched.
;;;
;;; We already know at this point that the first three bytes of the
;;; strings match each other, and they can be safely passed over before
;;; starting the compare loop. So what this code does is skip over 0-3
;;; bytes, as much as necessary in order to dword-align the edi
;;; pointer. (esi will still be misaligned three times out of four.)
;;;
;;; It should be confessed that this loop usually does not represent
;;; much of the total running time. Replacing it with a more
;;; straightforward "rep cmpsb" would not drastically degrade
;;; performance.
LoopCmps:
mov eax, [esi + edx]
xor eax, [edi + edx]
jnz LeaveLoopCmps
mov eax, [esi + edx + 4]
xor eax, [edi + edx + 4]
jnz LeaveLoopCmps4
add edx, 8
jnz LoopCmps
jmp short LenMaximum
LeaveLoopCmps4: add edx, 4
LeaveLoopCmps: test eax, 0000FFFFh
jnz LenLower
add edx, 2
shr eax, 16
LenLower: sub al, 1
adc edx, 0
;;; Calculate the length of the match. If it is longer than MAX_MATCH,
;;; then automatically accept it as the best possible match and leave.
lea eax, [edi + edx]
mov edi, [scan]
sub eax, edi
cmp eax, MAX_MATCH
jge LenMaximum
;;; If the length of the match is not longer than the best match we
;;; have so far, then forget it and return to the lookup loop.
mov edx, [deflatestate]
mov ebx, [bestlen]
cmp eax, ebx
jg LongerMatch
mov esi, [windowbestlen]
mov edi, [edx + dsPrev]
mov ebx, [scanend]
mov edx, [chainlenwmask]
jmp LookupLoop
;;; s->match_start = cur_match;
;;; best_len = len;
;;; if (len >= nice_match) break;
;;; scan_end = *(ushf*)(scan+best_len-1);
LongerMatch: mov ebx, [nicematch]
mov [bestlen], eax
mov [edx + dsMatchStart], ecx
cmp eax, ebx
jge LeaveNow
mov esi, [window]
add esi, eax
mov [windowbestlen], esi
movzx ebx, word ptr [edi + eax - 1]
mov edi, [edx + dsPrev]
mov [scanend], ebx
mov edx, [chainlenwmask]
jmp LookupLoop
;;; Accept the current string, with the maximum possible length.
LenMaximum: mov edx, [deflatestate]
mov dword ptr [bestlen], MAX_MATCH
mov [edx + dsMatchStart], ecx
;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
;;; return s->lookahead;
LeaveNow:
mov edx, [deflatestate]
mov ebx, [bestlen]
mov eax, [edx + dsLookahead]
cmp ebx, eax
jg LookaheadRet
mov eax, ebx
LookaheadRet:
;;; Restore the stack and return from whence we came.
add esp, LocalVarsSize
pop ebx
pop esi
pop edi
pop ebp
ret
; please don't remove this string !
; Your can freely use match686 in any free or commercial app if you don't remove the string in the binary!
db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
IFDEF NOUNDERLINE
longest_match endp
ELSE
_longest_match endp
ENDIF
IFDEF NOUNDERLINE
match_init proc near
ret
match_init endp
ELSE
_match_init proc near
ret
_match_init endp
ENDIF
_TEXT ends
end