├── .gitignore ├── src ├── graphics │ ├── dc.ico │ ├── DIALOG.APS │ ├── focused.bmp │ ├── lomaet.bmp │ ├── pushed.bmp │ ├── graphicIds.h │ ├── policeman-final-original.png │ ├── DIALOG.RC │ ├── Generator.manifest │ └── resource.h ├── section.h ├── rsa_key_creator │ ├── keyserialize.h │ ├── rsakey.h │ ├── code.cpp │ ├── keyserialize.cpp │ ├── CMakeLists.txt │ └── rsakey.cpp ├── clip.h ├── peparser.h ├── peparser.cpp ├── disasm.h ├── keygen.h ├── clip.cpp ├── CMakeLists.txt ├── disasm.cpp ├── patch.h ├── keygen.cpp ├── code.cpp └── patch.cpp ├── README.md ├── .gitmodules ├── prebuild ├── build.bat ├── CMakeLists_libtommath.txt ├── rsa_export.c └── ResourceDirectory.h └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/.gitignore -------------------------------------------------------------------------------- /src/graphics/dc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/src/graphics/dc.ico -------------------------------------------------------------------------------- /src/graphics/DIALOG.APS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/src/graphics/DIALOG.APS -------------------------------------------------------------------------------- /src/graphics/focused.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/src/graphics/focused.bmp -------------------------------------------------------------------------------- /src/graphics/lomaet.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/src/graphics/lomaet.bmp -------------------------------------------------------------------------------- /src/graphics/pushed.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/src/graphics/pushed.bmp -------------------------------------------------------------------------------- /src/graphics/graphicIds.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define IDB_PUSHED 3001 4 | #define IDB_BITMAP1 3003 5 | #define IDB_FOCUSED 3002 -------------------------------------------------------------------------------- /src/graphics/policeman-final-original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dc8044/sublime-megre-keygen/HEAD/src/graphics/policeman-final-original.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Before build process starts 2 | 3 | * Install Visual Studio 2019, cmake, git for windows 4 | * Make `git clone --recursive` to download dependencies 5 | 6 | 7 | # How to build the project. 8 | 9 | * `cd build` 10 | * `cmake .. -G "Visual Studio 16 2019" -A Win32` 11 | * `cmake --build . --target ALL_BUILD --config RelWithDebInfo` -------------------------------------------------------------------------------- /src/section.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct SectionData 5 | { 6 | uint64_t RawData; 7 | uint64_t RawSize; 8 | uint64_t VirtualAddress; 9 | uint64_t VirtualSize; 10 | SectionData(uint64_t RD, uint64_t RS, uint64_t VA, uint64_t VS) : 11 | RawData(RD), 12 | RawSize(RS), 13 | VirtualAddress(VA), 14 | VirtualSize(VS) 15 | { } 16 | }; -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libtommath"] 2 | path = libtommath 3 | url = https://github.com/libtom/libtommath.git 4 | [submodule "libtomcrypt"] 5 | path = libtomcrypt 6 | url = https://github.com/libtom/libtomcrypt.git 7 | [submodule "zydis"] 8 | path = zydis 9 | url = https://github.com/zyantific/zydis.git 10 | [submodule "pelib"] 11 | path = pelib 12 | url = https://github.com/avast/pelib.git 13 | -------------------------------------------------------------------------------- /src/rsa_key_creator/keyserialize.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | class Serialize 7 | { 8 | public: 9 | static void save(const std::string& filepath, const std::vector& values, 10 | const std::string& paramName); 11 | 12 | Serialize() = delete; 13 | ~Serialize() = delete; 14 | Serialize(const Serialize&) = delete; 15 | Serialize(Serialize&&) = delete; 16 | Serialize& operator=(const Serialize&) = delete; 17 | Serialize& operator=(Serialize&&) = delete; 18 | }; -------------------------------------------------------------------------------- /src/rsa_key_creator/rsakey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | extern "C" 6 | { 7 | #define LTC_SPRNG 8 | #define LTM_DESC 9 | #include 10 | #include 11 | } 12 | 13 | class RSATool 14 | { 15 | public: 16 | std::vector GeneratePublicKey() const; 17 | std::vector GeneratePrivateKey() const; 18 | RSATool(); 19 | ~RSATool() = default; 20 | RSATool(const RSATool&) = delete; 21 | RSATool(RSATool&&) = delete; 22 | RSATool& operator=(const RSATool&) = delete; 23 | RSATool& operator=(RSATool&&) = delete; 24 | 25 | private: 26 | rsa_key key = { 0 }; 27 | }; -------------------------------------------------------------------------------- /prebuild/build.bat: -------------------------------------------------------------------------------- 1 | copy ..\..\..\prebuild\rsa_export.c ..\..\..\libtomcrypt\src\pk\rsa /y 2 | copy ..\..\..\prebuild\ResourceDirectory.h ..\..\..\pelib\include\pelib /y 3 | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 4 | echo %cd% 5 | cd ..\..\..\libtommath 6 | copy ..\prebuild\CMakeLists_libtommath.txt CMakeLists.txt /y 7 | mkdir build 8 | cd build 9 | cmake .. -G "Visual Studio 16 2019" -A Win32 10 | cmake --build . --target ALL_BUILD --config RelWithDebInfo 11 | cd .. 12 | copy build\Product\RelWithDebInfo\libtommath.lib tommath.lib /y 13 | cd ..\libtomcrypt 14 | nmake -f makefile.msvc all -------------------------------------------------------------------------------- /src/clip.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class GlobalMemory 8 | { 9 | public: 10 | explicit GlobalMemory(SIZE_T size); 11 | ~GlobalMemory() noexcept; 12 | HGLOBAL GetAllocationHandle() const noexcept; 13 | GlobalMemory() = delete; 14 | GlobalMemory(const GlobalMemory&) = delete; 15 | GlobalMemory(GlobalMemory&&) = delete; 16 | GlobalMemory& operator=(const GlobalMemory&) = delete; 17 | GlobalMemory& operator=(GlobalMemory&&) = delete; 18 | 19 | private: 20 | HGLOBAL allocation; 21 | }; 22 | 23 | class ClipBoard 24 | { 25 | public: 26 | explicit ClipBoard(HWND hwnd); 27 | ~ClipBoard() noexcept; 28 | void SetTextToClipboard(const std::string& Text); 29 | }; -------------------------------------------------------------------------------- /src/peparser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "section.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class Parser 13 | { 14 | public: 15 | explicit Parser(const std::string& PathToExe); 16 | std::vector getExecutableSections() const; 17 | uint64_t getImageBase() const; 18 | uint64_t rawToRva(uint64_t rawValue) const; 19 | Parser() = delete; 20 | ~Parser() = default; 21 | Parser(const Parser&) = delete; 22 | Parser(Parser&&) = delete; 23 | Parser& operator=(const Parser&) = delete; 24 | Parser& operator=(Parser&&) = delete; 25 | 26 | private: 27 | std::unique_ptr pefile; 28 | std::unique_ptr peheader; 29 | }; -------------------------------------------------------------------------------- /src/graphics/DIALOG.RC: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | 3 | #define IDB_PUSHED 3001 4 | #define IDB_FOCUSED 3002 5 | #define IDB_BITMAP1 3003 6 | #define IDC_STATIC 3004 7 | 8 | #define IDM_GETTEXT 32000 9 | #define IDM_CLEAR 32001 10 | #define IDM_EXIT 32003 11 | 12 | 1 24 "Generator.manifest" 13 | 14 | MyDialog DIALOG 10, 10, 188, 280 15 | STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX | 16 | WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK 17 | CAPTION "Sublime Merge Keygen" 18 | BEGIN 19 | 20 | END 21 | 22 | IDB_BITMAP1 BITMAP "lomaet.bmp" 23 | IDB_FOCUSED BITMAP "focused.bmp" 24 | IDB_PUSHED BITMAP "pushed.bmp" 25 | MAINICON ICON "dc.ico" -------------------------------------------------------------------------------- /src/rsa_key_creator/code.cpp: -------------------------------------------------------------------------------- 1 | #include "rsakey.h" 2 | #include "keyserialize.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc,char* argv[]) try 9 | { 10 | if (argc == 2) 11 | { 12 | std::filesystem::path binaryPath(argv[1]); 13 | RSATool tool; 14 | auto privateKey = tool.GeneratePrivateKey(); 15 | auto publicKey = tool.GeneratePublicKey(); 16 | 17 | std::filesystem::path privateKeyFile(binaryPath / "privateKey.h"); 18 | std::filesystem::path publicKeyFile(binaryPath / "publicKey.h"); 19 | 20 | Serialize::save(privateKeyFile.string(), privateKey, "privateKey"); 21 | Serialize::save(publicKeyFile.string(), publicKey, "publicKey"); 22 | } 23 | 24 | return 0; 25 | } 26 | catch (const std::exception& error) 27 | { 28 | std::cout << error.what() << std::endl; 29 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(keygen LANGUAGES CXX) 3 | 4 | set(CMAKE_CXX_STANDARD 17) 5 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 6 | set(CMAKE_CXX_EXTENSIONS OFF) 7 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 8 | 9 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MD /O0") 10 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /O2") 11 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT /O2") 12 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MD /O0") 13 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT /O2") 14 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT /O2") 15 | 16 | add_subdirectory(src) 17 | add_subdirectory(zydis) 18 | add_dependencies(Generator Zydis) 19 | add_subdirectory(pelib) 20 | add_dependencies(Generator pelib) 21 | add_dependencies(pelib rsa_key_creator) -------------------------------------------------------------------------------- /src/graphics/Generator.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | 12 | elevate execution level 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/rsa_key_creator/keyserialize.cpp: -------------------------------------------------------------------------------- 1 | #include "keyserialize.h" 2 | 3 | #include 4 | #include 5 | 6 | void Serialize::save(const std::string& filepath, const std::vector& values, 7 | const std::string& paramName) 8 | { 9 | std::string data; 10 | 11 | for (auto it = values.cbegin();it != values.cend();++it) 12 | { 13 | char tmp[3] = { 0 }; 14 | snprintf(tmp, sizeof(tmp), "%02X", *it); 15 | data += std::string("0x") + std::string(tmp); 16 | 17 | if (it != std::prev(values.cend())) 18 | { 19 | data += ", "; 20 | } 21 | } 22 | 23 | auto content = std::string("#pragma once\n#include \n#include \n") + 24 | std::string("constexpr std::array ") + paramName + 26 | std::string("= { ") + data + std::string("};"); 27 | 28 | std::fstream output(filepath,std::ios::out); 29 | output << content; 30 | output.close(); 31 | } 32 | -------------------------------------------------------------------------------- /src/rsa_key_creator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | get_filename_component(CUSTOM_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) 2 | project(${CUSTOM_NAME}) 3 | 4 | set(SOURCES rsakey.cpp code.cpp keyserialize.cpp) 5 | set(HEADERS rsakey.h keyserialize.h) 6 | 7 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 8 | include_directories(${CMAKE_SOURCE_DIR}/libtommath) 9 | include_directories(${CMAKE_SOURCE_DIR}/libtomcrypt/src/headers) 10 | add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES}) 11 | 12 | if (MSVC) 13 | set(BUILD_COMMAND "${CMAKE_SOURCE_DIR}/prebuild/build.bat") 14 | add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD COMMAND ${BUILD_COMMAND}) 15 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libtommath/tommath.lib) 16 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libtomcrypt/tomcrypt.lib) 17 | endif(MSVC) 18 | 19 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD 20 | COMMAND ${PROJECT_NAME} 21 | ARGS ${CMAKE_BINARY_DIR} 22 | COMMENT "RSA key pair generated") -------------------------------------------------------------------------------- /src/peparser.cpp: -------------------------------------------------------------------------------- 1 | #include "peparser.h" 2 | 3 | Parser::Parser(const std::string& PathToExe) 4 | { 5 | pefile = std::make_unique(PathToExe); 6 | pefile->readMzHeader(); 7 | pefile->readPeHeader(); 8 | peheader = std::make_unique(pefile->peHeader()); 9 | } 10 | 11 | std::vector Parser::getExecutableSections() const 12 | { 13 | const unsigned int ExecutableCode = 0x20000000; 14 | std::vector result; 15 | 16 | for (size_t i = 0; i < peheader->calcNumberOfSections(); i++) 17 | { 18 | if (peheader->getCharacteristics(i) & ExecutableCode) 19 | { 20 | result.emplace_back(peheader->getPointerToRawData(i), 21 | peheader->getSizeOfRawData(i), 22 | peheader->getVirtualAddress(i), 23 | peheader->getVirtualSize(i)); 24 | } 25 | } 26 | 27 | return std::forward(result); 28 | } 29 | 30 | uint64_t Parser::getImageBase() const 31 | { 32 | return peheader->getImageBase(); 33 | } 34 | 35 | uint64_t Parser::rawToRva(uint64_t rawValue) const 36 | { 37 | return peheader->offsetToRva(rawValue); 38 | } 39 | -------------------------------------------------------------------------------- /src/rsa_key_creator/rsakey.cpp: -------------------------------------------------------------------------------- 1 | #include "rsakey.h" 2 | #include 3 | 4 | std::vector RSATool::GeneratePublicKey() const 5 | { 6 | std::vector result(1024); 7 | unsigned long outlen = result.size(); 8 | 9 | if (rsa_export(reinterpret_cast (result.data()), 10 | &outlen, PK_PUBLIC, const_cast (&key)) != CRYPT_OK) 11 | { 12 | throw std::exception("Unable to save public key"); 13 | } 14 | 15 | result.resize(outlen); 16 | return result; 17 | } 18 | 19 | std::vector RSATool::GeneratePrivateKey() const 20 | { 21 | std::vector result(1024); 22 | unsigned long outlen = result.size(); 23 | 24 | if (rsa_export(reinterpret_cast (result.data()), 25 | &outlen, PK_PRIVATE, const_cast (&key)) != CRYPT_OK) 26 | { 27 | throw std::exception("Unable to save private key"); 28 | } 29 | 30 | result.resize(outlen); 31 | return result; 32 | } 33 | 34 | RSATool::RSATool() 35 | { 36 | static bool init = false; 37 | if (!init) 38 | { 39 | register_all_prngs(); 40 | ltc_mp = ltm_desc; 41 | init = true; 42 | } 43 | 44 | if (rsa_make_key(nullptr, find_prng("sprng"), 45 | 128, 17, &key) != CRYPT_OK) 46 | { 47 | throw std::exception("Bad rsa key creation"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/disasm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "section.h" 3 | 4 | #define ZYDIS_STATIC_DEFINE 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace dis 13 | { 14 | class Disassembler 15 | { 16 | public: 17 | explicit Disassembler(uint64_t ImageBase, const std::vector& binaryData); 18 | uint64_t GetRawAddressOfCheckFunction(uint64_t initVectorVirtualAddress, 19 | const SectionData& section) const; 20 | Disassembler() = delete; 21 | ~Disassembler() = default; 22 | Disassembler(const Disassembler&) = delete; 23 | Disassembler(Disassembler&&) = delete; 24 | Disassembler& operator=(const Disassembler&) = delete; 25 | Disassembler& operator=(Disassembler&&) = delete; 26 | 27 | private: 28 | uint64_t BaseOfImage; 29 | const std::vector& fileData; 30 | ZydisDecoder decoder; 31 | ZydisFormatter formatter; 32 | 33 | template 34 | inline std::string valueToStringHex(T value) const 35 | { 36 | std::stringstream stream; 37 | stream << std::hex << value; 38 | auto temp = stream.str(); 39 | std::for_each(temp.begin(), temp.end(), [](char& symbol) -> void 40 | { 41 | symbol = ::toupper(symbol); 42 | }); 43 | return temp; 44 | } 45 | }; 46 | } -------------------------------------------------------------------------------- /src/keygen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | extern "C" 9 | { 10 | #define LTC_SHA1 11 | #define LTC_RIJNDAEL 12 | #define LTC_SPRNG 13 | #define LTM_DESC 14 | #include 15 | } 16 | 17 | class CryptoInit 18 | { 19 | public: 20 | CryptoInit() = delete; 21 | ~CryptoInit() = delete; 22 | CryptoInit(const CryptoInit&) = delete; 23 | CryptoInit(CryptoInit&&) = delete; 24 | CryptoInit& operator=(const CryptoInit&) = delete; 25 | CryptoInit& operator=(CryptoInit&&) = delete; 26 | 27 | static inline void Init() 28 | { 29 | register_all_ciphers(); 30 | register_all_hashes(); 31 | register_all_prngs(); 32 | ltc_mp = ltm_desc; 33 | } 34 | }; 35 | 36 | class Keygen 37 | { 38 | public: 39 | std::string GenerateLicenseKeyByName(const std::string& Name) const; 40 | std::string GetName() const; 41 | 42 | private: 43 | uint32_t GenerateRandomSuffix() const; 44 | std::string MakeLicenseInfo(const std::string& UserName) const; 45 | std::vector CreateSHA1Hash(const std::string& UserName) const; 46 | std::vector SignHash(const std::vector& hashValue) const; 47 | std::string SignatureToString(const std::vector& signature) const; 48 | 49 | const char Separator = 0x0A; 50 | }; -------------------------------------------------------------------------------- /src/clip.cpp: -------------------------------------------------------------------------------- 1 | #include "clip.h" 2 | 3 | #include 4 | 5 | GlobalMemory::GlobalMemory(SIZE_T size) 6 | { 7 | allocation = GlobalAlloc(GMEM_MOVEABLE, size); 8 | if (!allocation) 9 | { 10 | throw std::exception("Unable to allocate global memory"); 11 | } 12 | } 13 | 14 | GlobalMemory::~GlobalMemory() noexcept 15 | { 16 | GlobalFree(allocation); 17 | } 18 | 19 | HGLOBAL GlobalMemory::GetAllocationHandle() const noexcept 20 | { 21 | return allocation; 22 | } 23 | 24 | ClipBoard::ClipBoard(HWND hwnd) 25 | { 26 | if (!OpenClipboard(hwnd)) 27 | { 28 | throw std::exception("Unable to open clipboard"); 29 | } 30 | 31 | if (!EmptyClipboard()) 32 | { 33 | CloseClipboard(); 34 | throw std::exception("Unable to clear clipboard"); 35 | } 36 | } 37 | 38 | ClipBoard::~ClipBoard() noexcept 39 | { 40 | CloseClipboard(); 41 | } 42 | 43 | void ClipBoard::SetTextToClipboard(const std::string& Text) 44 | { 45 | const auto size = Text.length() + 46 | sizeof(std::remove_reference_t::value_type); 47 | GlobalMemory gm(size); 48 | 49 | auto* buffer = static_cast (GlobalLock(gm.GetAllocationHandle())); 50 | if (!buffer) 51 | { 52 | throw std::exception("Unable to lock global memory"); 53 | } 54 | 55 | memcpy(buffer, Text.data(), size); 56 | GlobalUnlock(buffer); 57 | SetClipboardData(CF_TEXT, reinterpret_cast (gm.GetAllocationHandle())); 58 | } 59 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(Generator) 2 | 3 | set(SOURCES keygen.cpp code.cpp patch.cpp peparser.cpp disasm.cpp clip.cpp) 4 | set(HEADERS keygen.h patch.h peparser.h disasm.h section.h clip.h 5 | graphics/resource.h graphics/graphicIds.h) 6 | 7 | include_directories(${CMAKE_SOURCE_DIR}/pelib/include/) 8 | include_directories(${CMAKE_SOURCE_DIR}/pelib/include/pelib) 9 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 10 | include_directories(${CMAKE_BINARY_DIR}) 11 | include_directories(${CMAKE_SOURCE_DIR}/libtommath) 12 | include_directories(${CMAKE_SOURCE_DIR}/libtomcrypt/src/headers) 13 | include_directories(${CMAKE_SOURCE_DIR}/zydis/include) 14 | include_directories(${CMAKE_SOURCE_DIR}/zydis/dependencies/zycore/include) 15 | include_directories(${CMAKE_SOURCE_DIR}/zydis/msvc) 16 | 17 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") 18 | add_executable(${PROJECT_NAME} WIN32 19 | ${HEADERS} ${SOURCES} graphics/DIALOG.RC graphics/Generator.manifest) 20 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libtommath/tommath.lib) 21 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libtomcrypt/tomcrypt.lib) 22 | target_link_libraries(${PROJECT_NAME} Comdlg32.lib) 23 | target_link_libraries(${PROJECT_NAME} 24 | ${CMAKE_BINARY_DIR}/pelib/src/pelib/RelWithDebInfo/pelib.lib) 25 | target_link_libraries(${PROJECT_NAME} "Zydis") 26 | 27 | set(RSA_SUBPROJECT rsa_key_creator) 28 | add_subdirectory(${RSA_SUBPROJECT}) 29 | add_dependencies(${PROJECT_NAME} ${RSA_SUBPROJECT}) -------------------------------------------------------------------------------- /prebuild/CMakeLists_libtommath.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | get_filename_component(CUSTOM_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) 3 | project(${CUSTOM_NAME}) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 9 | 10 | if (MSVC) 11 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MD /O0") 12 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /O2") 13 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT /O2") 14 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MD /O0") 15 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT /O2") 16 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT /O2") 17 | endif(MSVC) 18 | 19 | set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 20 | set(HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 21 | set(PROJECT_DIRS ${HEADERS_DIR} ${SOURCE_DIR}) 22 | FOREACH(PROJECT_DIR ${PROJECT_DIRS}) 23 | include_directories(${PROJECT_DIR}) 24 | 25 | file(GLOB SOURCES_ITERATOR "${PROJECT_DIR}/*.c") 26 | FOREACH(SOURCE ${SOURCES_ITERATOR}) 27 | set(SOURCES ${SOURCES} ${SOURCE}) 28 | ENDFOREACH(SOURCE) 29 | 30 | file(GLOB HEADERS_ITERATOR "${PROJECT_DIR}/*.h") 31 | FOREACH(HEADER ${HEADERS_ITERATOR}) 32 | set(HEADERS ${HEADERS} ${HEADER}) 33 | ENDFOREACH(HEADER) 34 | ENDFOREACH(PROJECT_DIR) 35 | 36 | include_directories(${HEADERS_DIR}) 37 | add_library(${PROJECT_NAME} STATIC ${HEADERS} ${SOURCES}) 38 | 39 | set(PRODUCT_DIR ${CMAKE_CURRENT_BINARY_DIR}/Product) 40 | set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PRODUCT_DIR}) -------------------------------------------------------------------------------- /src/disasm.cpp: -------------------------------------------------------------------------------- 1 | #include "disasm.h" 2 | #include 3 | #include 4 | 5 | dis::Disassembler::Disassembler(uint64_t ImageBase, const std::vector& binaryData): 6 | BaseOfImage(ImageBase), 7 | fileData(binaryData) 8 | { 9 | auto status = ZydisDecoderInit(&decoder, 10 | ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64); 11 | if (ZYAN_FAILED(status)) 12 | { 13 | throw std::exception("Unable to init disassembler engine"); 14 | } 15 | 16 | status = ZydisFormatterInit(&formatter, ZYDIS_FORMATTER_STYLE_INTEL); 17 | if (ZYAN_FAILED(status)) 18 | { 19 | throw std::exception("Unable to init disassembler formatter"); 20 | } 21 | } 22 | 23 | uint64_t dis::Disassembler::GetRawAddressOfCheckFunction(uint64_t initVectorVirtualAddress, 24 | const SectionData& section) const 25 | { 26 | ZyanU64 analyzedBytes = section.RawData; 27 | const ZyanU64 allBytesSize = section.RawData + section.RawSize; 28 | ZyanU64 runtime_address = section.VirtualAddress + BaseOfImage; 29 | std::string hexInitVectorVA = std::move(valueToStringHex(initVectorVirtualAddress)); 30 | bool retnDetected = false; 31 | uint64_t result = analyzedBytes; 32 | 33 | while (analyzedBytes < allBytesSize) 34 | { 35 | ZydisDecodedInstruction instruction; 36 | auto status = ZydisDecoderDecodeBuffer(&decoder, fileData.data() + analyzedBytes, 37 | static_cast (allBytesSize - analyzedBytes), &instruction); 38 | if (ZYAN_SUCCESS(status)) 39 | { 40 | char buffer[256] = { 0 }; 41 | ZydisFormatterFormatInstruction(&formatter, &instruction, buffer, sizeof(buffer), 42 | runtime_address); 43 | 44 | const auto testOfInstruction = std::string(buffer); 45 | if (testOfInstruction.find("ret") != std::string::npos) 46 | { 47 | retnDetected = true; 48 | } 49 | else if (retnDetected) 50 | { 51 | retnDetected = false; 52 | result = analyzedBytes; 53 | } 54 | 55 | if (testOfInstruction.find(hexInitVectorVA) != 56 | std::string::npos) 57 | { 58 | return result; 59 | } 60 | 61 | analyzedBytes += instruction.length; 62 | runtime_address += instruction.length; 63 | } 64 | else 65 | { 66 | analyzedBytes++; 67 | runtime_address++; 68 | } 69 | } 70 | 71 | throw std::exception("Unable to find address in this section"); 72 | } -------------------------------------------------------------------------------- /src/patch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "peparser.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class patch 11 | { 12 | public: 13 | explicit patch(const std::string& Path); 14 | void Replace(const std::vector& data, const std::vector& patched, 15 | const std::string& resultFileName); 16 | std::vector GetOldPublicKey() const; 17 | std::vector GetNewPublicKey() const; 18 | static void FixPublicKey(); 19 | 20 | void FixPublicKeyPatchCheck(); 21 | ~patch() = default; 22 | patch() = delete; 23 | patch(const patch&) = delete; 24 | patch(patch&&) = delete; 25 | patch& operator=(const patch&) = delete; 26 | patch& operator=(patch&&) = delete; 27 | 28 | private: 29 | Parser peparser; 30 | std::vector fileData; 31 | static std::string GetFileToPatch(); 32 | uint64_t FindSha256SignatureRawPosition() const; 33 | uint64_t GetRawSha256Address(uint64_t InitVectorAddress) const; 34 | void PatchSha256Check(uint64_t CheckOffset); 35 | 36 | const std::array publicOldKey 37 | { 38 | 0x30, 0x81, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 39 | 0x05, 0x00, 0x03, 0x81, 0x8B, 0x00, 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0xD8, 0x7B, 0xA2, 40 | 0x45, 0x62, 0xF7, 0xC5, 0xD1, 0x4A, 0x0C, 0xFB, 0x12, 0xB9, 0x74, 0x0C, 0x19, 0x5C, 0x6B, 0xDC, 41 | 0x7E, 0x6D, 0x6E, 0xC9, 0x2B, 0xAC, 0x0E, 0xB2, 0x9D, 0x59, 0xE1, 0xD9, 0xAE, 0x67, 0x89, 0x0C, 42 | 0x2B, 0x88, 0xC3, 0xAB, 0xDC, 0xAF, 0xFE, 0x7D, 0x4A, 0x33, 0xDC, 0xC1, 0xBF, 0xBE, 0x53, 0x1A, 43 | 0x25, 0x1C, 0xEF, 0x0C, 0x92, 0x3F, 0x06, 0xBE, 0x79, 0xB2, 0x32, 0x85, 0x59, 0xAC, 0xFE, 0xE9, 44 | 0x86, 0xD5, 0xE1, 0x5E, 0x4D, 0x17, 0x66, 0xEA, 0x56, 0xC4, 0xE1, 0x06, 0x57, 0xFA, 0x74, 0xDB, 45 | 0x09, 0x77, 0xC3, 0xFB, 0x75, 0x82, 0xB7, 0x8C, 0xD4, 0x7B, 0xB2, 0xC7, 0xF9, 0xB2, 0x52, 0xB4, 46 | 0xA9, 0x46, 0x3D, 0x15, 0xF6, 0xAE, 0x6E, 0xE9, 0x23, 0x7D, 0x54, 0xC5, 0x48, 0x1B, 0xF3, 0xE0, 47 | 0xB0, 0x99, 0x20, 0x19, 0x0B, 0xCF, 0xB3, 0x1E, 0x5B, 0xE5, 0x09, 0xC3, 0x3B, 0x02, 0x01, 0x11 48 | }; 49 | const std::array sha256signature{ 50 | 0x6A, 0x09, 0xE6, 0x67, 0xBB, 0x67, 0xAE, 0x85, 0x3C, 0x6E, 0xF3, 0x72, 0xA5, 0x4F, 0xF5, 0x3A, 51 | 0x51, 0x0E, 0x52, 0x7F, 0x9B, 0x05, 0x68, 0x8C, 0x1F, 0x83, 0xD9, 0xAB, 0x5B, 0xE0, 0xCD, 0x19 52 | }; 53 | }; 54 | 55 | -------------------------------------------------------------------------------- /prebuild/rsa_export.c: -------------------------------------------------------------------------------- 1 | /* LibTomCrypt, modular cryptographic library -- Tom St Denis 2 | * 3 | * LibTomCrypt is a library that provides various cryptographic 4 | * algorithms in a highly modular and flexible manner. 5 | * 6 | * The library is free for all purposes without any express 7 | * guarantee it works. 8 | */ 9 | #include "tomcrypt.h" 10 | 11 | /** 12 | @file rsa_export.c 13 | Export RSA PKCS keys, Tom St Denis 14 | */ 15 | 16 | #ifdef LTC_MRSA 17 | 18 | /** 19 | This will export either an RSAPublicKey or RSAPrivateKey [defined in PKCS #1 v2.1] 20 | @param out [out] Destination of the packet 21 | @param outlen [in/out] The max size and resulting size of the packet 22 | @param type The type of exported key (PK_PRIVATE or PK_PUBLIC) 23 | @param key The RSA key to export 24 | @return CRYPT_OK if successful 25 | */ 26 | int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key) 27 | { 28 | unsigned long zero=0; 29 | int err; 30 | LTC_ARGCHK(out != NULL); 31 | LTC_ARGCHK(outlen != NULL); 32 | LTC_ARGCHK(key != NULL); 33 | 34 | /* type valid? */ 35 | if (!(key->type == PK_PRIVATE) && (type == PK_PRIVATE)) { 36 | return CRYPT_PK_INVALID_TYPE; 37 | } 38 | 39 | if (type == PK_PRIVATE) { 40 | /* private key */ 41 | /* output is 42 | Version, n, e, d, p, q, d mod (p-1), d mod (q - 1), 1/q mod p 43 | */ 44 | return der_encode_sequence_multi(out, outlen, 45 | LTC_ASN1_SHORT_INTEGER, 1UL, &zero, 46 | LTC_ASN1_INTEGER, 1UL, key->N, 47 | LTC_ASN1_INTEGER, 1UL, key->e, 48 | LTC_ASN1_INTEGER, 1UL, key->d, 49 | LTC_ASN1_INTEGER, 1UL, key->p, 50 | LTC_ASN1_INTEGER, 1UL, key->q, 51 | LTC_ASN1_INTEGER, 1UL, key->dP, 52 | LTC_ASN1_INTEGER, 1UL, key->dQ, 53 | LTC_ASN1_INTEGER, 1UL, key->qP, 54 | LTC_ASN1_EOL, 0UL, NULL); 55 | } else { 56 | /* public key */ 57 | unsigned long tmplen, *ptmplen; 58 | unsigned char* tmp = NULL; 59 | 60 | if (type | PK_STD) { 61 | tmplen = (unsigned long)(mp_count_bits(key->N) / 8) * 2 + 8; 62 | tmp = XMALLOC(tmplen); 63 | ptmplen = &tmplen; 64 | if (tmp == NULL) { 65 | return CRYPT_MEM; 66 | } 67 | } 68 | else { 69 | tmp = out; 70 | ptmplen = outlen; 71 | } 72 | 73 | err = der_encode_sequence_multi(tmp, ptmplen, 74 | LTC_ASN1_INTEGER, 1UL, key->N, 75 | LTC_ASN1_INTEGER, 1UL, key->e, 76 | LTC_ASN1_EOL, 0UL, NULL); 77 | 78 | if ((err != CRYPT_OK) || !(type | PK_STD)) { 79 | goto finish; 80 | } 81 | 82 | err = der_encode_subject_public_key_info(out, outlen, 83 | PKA_RSA, tmp, tmplen, LTC_ASN1_NULL, NULL, 0); 84 | 85 | finish: 86 | if (tmp != out) 87 | XFREE(tmp); 88 | return err; 89 | 90 | } 91 | } 92 | 93 | #endif /* LTC_MRSA */ 94 | 95 | /* ref: $Format:%D$ */ 96 | /* git commit: $Format:%H$ */ 97 | /* commit time: $Format:%ai$ */ 98 | -------------------------------------------------------------------------------- /src/keygen.cpp: -------------------------------------------------------------------------------- 1 | #include "keygen.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | std::vector Keygen::CreateSHA1Hash(const std::string& licenseData) const 8 | { 9 | const unsigned int sha1Len = 20; 10 | const auto hashId = find_hash("sha1"); 11 | std::vector result(sha1Len); 12 | unsigned long size = result.size(); 13 | 14 | auto cryptResult = hash_memory(hashId, (const unsigned char*) (licenseData.data()), 15 | static_cast (licenseData.size()), result.data(), &size); 16 | 17 | if (cryptResult != CRYPT_OK) 18 | { 19 | auto message = std::string("Error in hash calculation: ") + 20 | std::to_string(cryptResult); 21 | throw std::exception(message.c_str()); 22 | } 23 | 24 | return result; 25 | } 26 | 27 | std::vector Keygen::SignHash(const std::vector& hashValue) const 28 | { 29 | rsa_key key; 30 | std::vector result(500, 0); 31 | unsigned long size = result.size(); 32 | 33 | if (auto res = rsa_import(privateKey.data(), 34 | static_cast (privateKey.size()), 35 | &key) != CRYPT_OK) 36 | { 37 | auto message = std::string("Unable to import key, code: ") + 38 | std::to_string(res); 39 | throw std::exception(message.c_str()); 40 | } 41 | 42 | if (auto res = rsa_sign_hash_ex(hashValue.data(), hashValue.size(), result.data(), 43 | &size, LTC_PKCS_1_V1_5, nullptr, 0, find_hash("sha1"), 0, &key) != CRYPT_OK) 44 | { 45 | rsa_free(&key); 46 | auto message = std::string("Unable to sign data, code: ") + 47 | std::to_string(res); 48 | throw std::exception(message.c_str()); 49 | } 50 | 51 | result.resize(size); 52 | rsa_free(&key); 53 | return std::forward (result); 54 | } 55 | 56 | std::string Keygen::SignatureToString(const std::vector& signature) const 57 | { 58 | std::string result; 59 | int symbolsOnLine = 0; 60 | const int symbolsPerLine = 16; 61 | 62 | for (const auto& element : signature) 63 | { 64 | if (symbolsOnLine == symbolsPerLine) 65 | { 66 | symbolsOnLine = 0; 67 | result += Separator; 68 | } 69 | 70 | char tmp[3] = { 0 }; 71 | snprintf(tmp, sizeof(tmp), "%02X", element); 72 | result += std::string(tmp); 73 | ++symbolsOnLine; 74 | } 75 | 76 | return std::forward (result); 77 | } 78 | 79 | std::string Keygen::GenerateLicenseKeyByName(const std::string& Name) const 80 | { 81 | auto licenseInfo = MakeLicenseInfo(Name); 82 | auto hash = CreateSHA1Hash(licenseInfo); 83 | auto sign = SignHash(hash); 84 | auto printableSignature = SignatureToString(sign); 85 | return licenseInfo + static_cast (0x0A) + printableSignature; 86 | } 87 | 88 | std::string Keygen::GetName() const 89 | { 90 | constexpr DWORD startLenght = 100; 91 | constexpr unsigned int MaxNameLength = 17; 92 | std::vector buffer(startLenght, 0); 93 | DWORD bufferLength = buffer.size(); 94 | 95 | while (!GetUserNameA(reinterpret_cast (buffer.data()), &bufferLength)) 96 | { 97 | bufferLength = buffer.size() * 2; 98 | buffer.resize(bufferLength); 99 | memset(buffer.data(), 0, buffer.size()); 100 | } 101 | 102 | const auto realLength = strlen(buffer.data()); 103 | if (realLength > MaxNameLength) 104 | { 105 | return std::forward(std::string(buffer.cbegin(), 106 | buffer.cbegin() + MaxNameLength)); 107 | } 108 | 109 | return std::forward(std::string(buffer.cbegin(), 110 | buffer.cbegin() + realLength)); 111 | } 112 | 113 | uint32_t Keygen::GenerateRandomSuffix() const 114 | { 115 | std::srand(static_cast (std::time(0))); 116 | return static_cast (std::rand()); 117 | } 118 | 119 | std::string Keygen::MakeLicenseInfo(const std::string& UserName) const 120 | { 121 | const std::string Prefix("E52D"); 122 | const std::string LicenseType = "Unlimited User License"; 123 | const auto suffix = GenerateRandomSuffix(); 124 | 125 | return UserName + Separator + LicenseType + Separator + 126 | Prefix + '-' + std::to_string(suffix); 127 | } 128 | -------------------------------------------------------------------------------- /src/code.cpp: -------------------------------------------------------------------------------- 1 | #include "patch.h" 2 | #include "keygen.h" 3 | #include "graphics/graphicIds.h" 4 | #include "clip.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | enum class ButtonState 13 | { 14 | Default, 15 | Focused, 16 | Pushed 17 | }; 18 | 19 | bool IsKeygenFocused(LPARAM lParam) 20 | { 21 | auto xPos = GET_X_LPARAM(lParam); 22 | auto yPos = GET_Y_LPARAM(lParam); 23 | 24 | if (xPos >= 269 && xPos <= 381 && 25 | yPos >= 359 && yPos <= 389) 26 | { 27 | return true; 28 | } 29 | 30 | return false; 31 | } 32 | 33 | void DrawObject(HDC hdc, HDC hdcbitmap, HBITMAP bitmap, int x, int y) 34 | { 35 | BITMAP bm; 36 | 37 | auto hOldBitmap = reinterpret_cast (SelectObject(hdcbitmap, bitmap)); 38 | GetObject(bitmap, sizeof(BITMAP), &bm); 39 | BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcbitmap, 40 | 0, 0, SRCCOPY); 41 | SelectObject(hdcbitmap, hOldBitmap); 42 | } 43 | 44 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 45 | { 46 | static HBITMAP Logo = LoadBitmapA(GetModuleHandleA(nullptr), 47 | MAKEINTRESOURCEA(IDB_BITMAP1)); 48 | static HBITMAP FocusedButton = LoadBitmapA(GetModuleHandleA(nullptr), 49 | MAKEINTRESOURCEA(IDB_FOCUSED)); 50 | static HBITMAP PushedButton = LoadBitmapA(GetModuleHandleA(nullptr), 51 | MAKEINTRESOURCEA(IDB_PUSHED)); 52 | static ButtonState state = ButtonState::Default; 53 | static constexpr RECT rectangle{ 269, 359, 381, 389 }; 54 | 55 | switch (uMsg) 56 | { 57 | case WM_MOUSEMOVE: 58 | { 59 | state = (IsKeygenFocused(lParam)) ? ButtonState::Focused 60 | : ButtonState::Default; 61 | SendMessageA(hwnd, WM_PAINT, 0, 0); 62 | } 63 | break; 64 | case WM_LBUTTONDOWN: 65 | { 66 | if (IsKeygenFocused(lParam)) 67 | { 68 | state = ButtonState::Pushed; 69 | SendMessageA(hwnd, WM_PAINT, 0, 0); 70 | 71 | try { 72 | Keygen generator; 73 | ClipBoard clip(GetDesktopWindow()); 74 | const auto& UserName = generator.GetName(); 75 | auto license = generator.GenerateLicenseKeyByName(UserName); 76 | for (auto it = license.begin(); it != std::prev(license.end()); ++it) 77 | { 78 | if (*it == 0x0A) 79 | { 80 | *it = '\r'; 81 | it = license.insert(std::next(it), '\n'); 82 | } 83 | } 84 | patch::FixPublicKey(); 85 | clip.SetTextToClipboard(license); 86 | MessageBoxA(hwnd, "Key was copied to clipboard", 87 | "Success", MB_ICONEXCLAMATION); 88 | } 89 | catch (const std::exception& error) 90 | { 91 | MessageBoxA(hwnd, (LPSTR)error.what(), "Error", MB_ICONERROR); 92 | } 93 | } 94 | } 95 | break; 96 | case WM_PAINT: 97 | { 98 | InvalidateRect(hwnd, &rectangle, TRUE); 99 | 100 | PAINTSTRUCT ps; 101 | auto hDC = BeginPaint(hwnd, &ps); 102 | auto hBitmapDC = CreateCompatibleDC(hDC); 103 | 104 | if (state == ButtonState::Focused) 105 | { 106 | DrawObject(hDC, hBitmapDC, FocusedButton, 107 | rectangle.left, rectangle.top); 108 | } 109 | else if (state == ButtonState::Pushed) 110 | { 111 | DrawObject(hDC, hBitmapDC, PushedButton, 112 | rectangle.left, rectangle.top); 113 | } 114 | else 115 | { 116 | DrawObject(hDC, hBitmapDC, Logo, 0, 0); 117 | } 118 | 119 | DeleteDC(hBitmapDC); 120 | EndPaint(hwnd, &ps); 121 | return FALSE; 122 | } 123 | break; 124 | case WM_INITDIALOG: 125 | CryptoInit::Init(); 126 | break; 127 | case WM_CLOSE: 128 | DeleteObject(Logo); 129 | DeleteObject(FocusedButton); 130 | DeleteObject(PushedButton); 131 | EndDialog(hwnd, NULL); 132 | break; 133 | default: 134 | return FALSE; 135 | } 136 | 137 | return TRUE; 138 | } 139 | 140 | int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, 141 | LPSTR lpCmdLine,int nShowCmd) 142 | { 143 | if (DialogBoxParamA(GetModuleHandle(nullptr), "MyDialog", 144 | NULL, reinterpret_cast (DialogProc), NULL) < 0) 145 | { 146 | MessageBoxA(NULL, std::to_string(GetLastError()).c_str(), "Error", MB_ICONERROR); 147 | } 148 | return 0; 149 | } -------------------------------------------------------------------------------- /src/patch.cpp: -------------------------------------------------------------------------------- 1 | #include "patch.h" 2 | #include "disasm.h" 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | patch::patch(const std::string& Path): 11 | peparser(Path) 12 | { 13 | std::ifstream input(Path,std::ios::binary); 14 | 15 | if (!input.is_open()) 16 | { 17 | auto message = "Unable to open file " + Path; 18 | throw std::exception(message.c_str()); 19 | } 20 | 21 | input.seekg(0, input.end); 22 | const auto fileSize = static_cast (input.tellg()); 23 | input.seekg(0, input.beg); 24 | fileData.resize(fileSize); 25 | 26 | input.read(reinterpret_cast (fileData.data()), fileData.size()); 27 | if (!input) 28 | { 29 | throw std::exception("Unable to read the whole file"); 30 | } 31 | } 32 | 33 | void patch::Replace(const std::vector& data, const std::vector& patched, 34 | const std::string& resultFileName) 35 | { 36 | if (data.size() != patched.size()) 37 | { 38 | throw std::exception("Data should be patched with the same size"); 39 | } 40 | 41 | auto patchPlace = std::search(fileData.cbegin(), fileData.cend(), data.cbegin(), data.cend()); 42 | if (patchPlace == fileData.cend()) 43 | { 44 | throw std::exception("Data not found in the target, nothing to patch"); 45 | } 46 | 47 | auto result = std::vector(fileData.cbegin(), patchPlace); 48 | std::copy(patched.cbegin(), patched.cend(), std::back_inserter(result)); 49 | auto tmp = std::vector(patchPlace + patched.size(), fileData.cend()); 50 | std::copy(tmp.cbegin(), tmp.cend(), std::back_inserter(result)); 51 | 52 | std::ofstream output(resultFileName, std::ios::binary); 53 | output.write(const_cast (reinterpret_cast (result.data())), result.size()); 54 | output.close(); 55 | } 56 | 57 | std::vector patch::GetOldPublicKey() const 58 | { 59 | return std::vector(publicOldKey.cbegin(), publicOldKey.cend()); 60 | } 61 | 62 | std::vector patch::GetNewPublicKey() const 63 | { 64 | return std::vector(publicKey.cbegin(), publicKey.cend()); 65 | } 66 | 67 | void patch::FixPublicKey() 68 | { 69 | std::string pathToExe = patch::GetFileToPatch(); 70 | patch Patcher(pathToExe); 71 | Patcher.FixPublicKeyPatchCheck(); 72 | 73 | auto oldKey = Patcher.GetOldPublicKey(); 74 | auto newKey = Patcher.GetNewPublicKey(); 75 | Patcher.Replace(oldKey, newKey, pathToExe); 76 | } 77 | 78 | void patch::FixPublicKeyPatchCheck() 79 | { 80 | const uint64_t initVectorPosition = FindSha256SignatureRawPosition(); 81 | const uint64_t checkProcPosition = GetRawSha256Address(initVectorPosition); 82 | PatchSha256Check(checkProcPosition); 83 | } 84 | 85 | std::string patch::GetFileToPatch() 86 | { 87 | char buffer[MAX_PATH] = { 0 }; 88 | OPENFILENAMEA fileName = { 0 }; 89 | fileName.lStructSize = sizeof(decltype(fileName)); 90 | fileName.lpstrFilter = "All Files\0*.*\0\0"; 91 | fileName.nMaxFile = sizeof(buffer); 92 | fileName.lpstrFile = buffer; 93 | 94 | if (GetOpenFileNameA(&fileName)) 95 | { 96 | return std::forward(std::string(fileName.lpstrFile)); 97 | } 98 | 99 | throw std::exception("Unable to open file for patching"); 100 | } 101 | 102 | uint64_t patch::FindSha256SignatureRawPosition() const 103 | { 104 | auto patchPlace = std::search(fileData.cbegin(), fileData.cend(), 105 | sha256signature.cbegin(), sha256signature.cend()); 106 | 107 | if (patchPlace == fileData.cend()) 108 | { 109 | throw std::exception("Unable to find init vector for sha256"); 110 | } 111 | 112 | return static_cast (std::distance(fileData.cbegin(), patchPlace)); 113 | } 114 | 115 | uint64_t patch::GetRawSha256Address(uint64_t InitVectorAddress) const 116 | { 117 | const auto sections = peparser.getExecutableSections(); 118 | const auto ImageBase = peparser.getImageBase(); 119 | const auto InitVectorVirtualAddress = peparser.rawToRva(InitVectorAddress) + ImageBase; 120 | dis::Disassembler disasm(ImageBase, fileData); 121 | 122 | for (const auto& section : sections) 123 | { 124 | try { 125 | return disasm.GetRawAddressOfCheckFunction(InitVectorVirtualAddress, section); 126 | } 127 | catch (const std::exception&) 128 | { 129 | continue; 130 | } 131 | } 132 | 133 | throw std::exception("Unable to find reference to sha256 init vector"); 134 | } 135 | 136 | void patch::PatchSha256Check(uint64_t CheckOffset) 137 | { 138 | static const std::array modifiedCode{ 139 | 0xC6, 0x41, 0x0F, 0xA8, //mov byte ptr [rcx+F], 0xA8 140 | 0xC6, 0x41, 0x1E, 0x56, //mov byte ptr [rcx+1E], 0x56 141 | 0xC3 //ret 142 | }; 143 | 144 | auto start = fileData.begin() + (const int) CheckOffset; 145 | for (const auto& v : modifiedCode) 146 | { 147 | *start = v; 148 | ++start; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /prebuild/ResourceDirectory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ResourceDirectory.cpp - Part of the PeLib library. 3 | * 4 | * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) 5 | * All rights reserved. 6 | * 7 | * This software is licensed under the zlib/libpng License. 8 | * For more details see http://www.opensource.org/licenses/zlib-license.php 9 | * or the license information file (license.htm) in the root directory 10 | * of PeLib. 11 | */ 12 | 13 | #ifndef RESOURCEDIRECTORY_H 14 | #define RESOURCEDIRECTORY_H 15 | 16 | #include 17 | 18 | #include "pelib/PeLibInc.h" 19 | #include "pelib/PeHeader.h" 20 | 21 | namespace PeLib 22 | { 23 | class ResourceElement; 24 | class ResourceDirectory; 25 | template class ResourceDirectoryT; 26 | 27 | /// The class ResourceChild is used to store information about a resource node. 28 | class ResourceChild 29 | { 30 | friend class ResourceElement; 31 | friend class ResourceDirectory; 32 | friend class ResourceNode; 33 | friend class ResourceLeaf; 34 | template friend class ResourceDirectoryT; 35 | 36 | /// Stores name and offset of a resource node. 37 | PELIB_IMG_RES_DIR_ENTRY entry; 38 | /// A pointer to one of the node's child nodes. 39 | ResourceElement* child; 40 | 41 | public: 42 | /// Function which compares a resource ID to the node's resource ID. 43 | bool equalId(dword wId) const; // EXPORT 44 | /// Function which compares a string to the node's resource name. 45 | bool equalName(std::string strName) const; // EXPORT 46 | /// Predicate that determines if a child is identified by name or by ID. 47 | bool isNamedResource() const; // EXPORT 48 | /// Used for sorting a node's children. 49 | bool operator<(const ResourceChild& rc) const; // EXPORT 50 | 51 | /// Returns the node's number of children. 52 | unsigned int getNumberOfChildren() const; // EXPORT 53 | /// Returns a child of this child. 54 | ResourceChild* getChildOfThisChild(std::size_t uiIndex); // EXPORT 55 | const ResourceChild* getChildOfThisChild(std::size_t uiIndex) const; // EXPORT 56 | 57 | /// Returns a pointer to ResourceElement. 58 | ResourceElement* getNode(); 59 | const ResourceElement* getNode() const; 60 | /// Sets a pointer to ResourceElement. 61 | void setNode(ResourceElement* node); 62 | 63 | /// Returns the name of the node. 64 | std::string getName() const; // EXPORT 65 | /// Returns the Name value of the node. 66 | dword getOffsetToName() const; // EXPORT 67 | /// Returns the OffsetToData value of the node. 68 | dword getOffsetToData() const; // EXPORT 69 | 70 | /// Sets the name of the node. 71 | void setName(const std::string& strNewName); // EXPORT 72 | /// Sets the Name value of the node. 73 | void setOffsetToName(dword dwNewOffset); // EXPORT 74 | /// Sets the OffsetToData value of the node. 75 | void setOffsetToData(dword dwNewOffset); // EXPORT 76 | 77 | /// Returns the size of a resource child. 78 | // unsigned int size() const; 79 | 80 | /// Standard constructor. Does absolutely nothing. 81 | ResourceChild(); 82 | /// Makes a deep copy of a ResourceChild object. 83 | ResourceChild(const ResourceChild& rhs); 84 | /// Makes a deep copy of a ResourceChild object. 85 | ResourceChild& operator=(const ResourceChild& rhs); 86 | /// Deletes a ResourceChild object. 87 | ~ResourceChild(); 88 | }; 89 | 90 | /// Base class for ResourceNode and ResourceLeaf, the elements of the resource tree. 91 | /// \todo write 92 | class ResourceElement 93 | { 94 | friend class ResourceChild; 95 | friend class ResourceNode; 96 | friend class ResourceLeaf; 97 | 98 | protected: 99 | /// Stores RVA of the resource element in the file. 100 | unsigned int uiElementRva; 101 | 102 | /// Reads the next resource element from the InputBuffer. 103 | virtual int read(std::istream&, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, ResourceDirectory* resDir) = 0; 104 | /// Writes the next resource element into the OutputBuffer. 105 | virtual void rebuild(OutputBuffer&, unsigned int, unsigned int, const std::string&) const = 0; 106 | /// Recalculates the tree for different RVA. 107 | virtual void recalculate(unsigned int& uiCurrentOffset, unsigned int uiNewRva) = 0; 108 | 109 | public: 110 | /// Returns the RVA of the element in the file. 111 | unsigned int getElementRva() const; // EXPORT 112 | /// Indicates if the resource element is a leaf or a node. 113 | virtual bool isLeaf() const = 0; // EXPORT 114 | /// Corrects erroneous values in the ResourceElement. 115 | virtual void makeValid() = 0; // EXPORT 116 | /// Returns the size of a resource element. 117 | // virtual unsigned int size() const = 0; 118 | /// Constructor 119 | ResourceElement(); 120 | /// Necessary virtual destructor. 121 | virtual ~ResourceElement() {} 122 | }; 123 | 124 | /// ResourceLeafs represent the leafs of the resource tree: The actual resources. 125 | class ResourceLeaf : public ResourceElement 126 | { 127 | friend class ResourceChild; 128 | friend class ResourceDirectory; 129 | template friend struct fixNumberOfEntries; 130 | template friend class ResourceDirectoryT; 131 | 132 | private: 133 | /// The resource data. 134 | std::vector m_data; 135 | /// PeLib equivalent of the Win32 structure IMAGE_RESOURCE_DATA_ENTRY 136 | PELIB_IMAGE_RESOURCE_DATA_ENTRY entry; 137 | 138 | protected: 139 | int read(std::istream& inStream, unsigned int uiRsrcOffset, unsigned int uiOffset, unsigned int uiRva, unsigned int uiFileSize, unsigned int uiSizeOfImage, ResourceDirectory* resDir); 140 | /// Writes the next resource leaf into the OutputBuffer. 141 | void rebuild(OutputBuffer&, unsigned int uiOffset, unsigned int uiRva, const std::string&) const; 142 | /// Recalculates the tree for different RVA. 143 | virtual void recalculate(unsigned int& uiCurrentOffset, unsigned int uiNewRva) override; 144 | 145 | public: 146 | /// Indicates if the resource element is a leaf or a node. 147 | bool isLeaf() const; // EXPORT 148 | /// Corrects erroneous values in the ResourceLeaf. 149 | void makeValid(); // EXPORT 150 | /// Reads the next resource leaf from the InputBuffer. 151 | /// Returns the size of a resource lead. 152 | // unsigned int size() const; 153 | 154 | /// Returns the resource data of this resource leaf. 155 | std::vector getData() const; // EXPORT 156 | /// Sets the resource data of this resource leaf. 157 | void setData(const std::vector& vData); // EXPORT 158 | 159 | /// Returns the OffsetToData value of this resource leaf. 160 | dword getOffsetToData() const; // EXPORT 161 | /// Returns the Size value of this resource leaf. 162 | dword getSize() const; // EXPORT 163 | /// Returns the CodePage value of this resource leaf. 164 | dword getCodePage() const; // EXPORT 165 | /// Returns the Reserved value of this resource leaf. 166 | dword getReserved() const; // EXPORT 167 | 168 | /// Sets the OffsetToData value of this resource leaf. 169 | void setOffsetToData(dword dwValue); // EXPORT 170 | /// Sets the Size value of this resource leaf. 171 | void setSize(dword dwValue); // EXPORT 172 | /// Sets the CodePage value of this resource leaf. 173 | void setCodePage(dword dwValue); // EXPORT 174 | /// Sets the Reserved value of this resource leaf. 175 | void setReserved(dword dwValue); // EXPORT 176 | /// Constructor 177 | ResourceLeaf(); 178 | /// Destructor 179 | virtual ~ResourceLeaf() override; 180 | }; 181 | 182 | /// ResourceNodes represent the nodes in the resource tree. 183 | class ResourceNode : public ResourceElement 184 | { 185 | friend class ResourceChild; 186 | friend class ResourceDirectory; 187 | template friend struct fixNumberOfEntries; 188 | template friend class ResourceDirectoryT; 189 | 190 | /// The node's children. 191 | std::vector children; 192 | /// The node's header. Equivalent to IMAGE_RESOURCE_DIRECTORY from the Win32 API. 193 | PELIB_IMAGE_RESOURCE_DIRECTORY header; 194 | 195 | protected: 196 | /// Reads the next resource node. 197 | int read(std::istream& inStream, unsigned int uiRsrcOffset, unsigned int uiOffset, unsigned int uiRva, unsigned int uiFileSize, unsigned int uiSizeOfImage, ResourceDirectory* resDir); 198 | /// Writes the next resource node into the OutputBuffer. 199 | void rebuild(OutputBuffer&, unsigned int uiOffset, unsigned int uiRva, const std::string&) const; 200 | /// Recalculates the tree for different RVA. 201 | virtual void recalculate(unsigned int& uiCurrentOffset, unsigned int uiNewRva) override; 202 | 203 | public: 204 | /// Indicates if the resource element is a leaf or a node. 205 | bool isLeaf() const; // EXPORT 206 | /// Corrects erroneous values in the ResourceNode. 207 | void makeValid(); // EXPORT 208 | 209 | /// Returns the node's number of children. 210 | unsigned int getNumberOfChildren() const; // EXPORT 211 | /// Adds another child to node. 212 | ResourceChild* addChild(); // EXPORT 213 | /// Returns a node's child. 214 | ResourceChild* getChild(std::size_t uiIndex); // EXPORT 215 | const ResourceChild* getChild(std::size_t uiIndex) const; // EXPORT 216 | /// Removes a node's child. 217 | void removeChild(unsigned int uiIndex); // EXPORT 218 | 219 | /// Returns the name of one of the node's children. 220 | std::string getChildName(unsigned int uiIndex) const; // EXPORT 221 | /// Returns the Name value of one of the node's children. 222 | dword getOffsetToChildName(unsigned int uiIndex) const; // EXPORT 223 | /// Returns the OffsetToData value of one of the node's children. 224 | dword getOffsetToChildData(unsigned int uiIndex) const; // EXPORT 225 | 226 | /// Sets the name of one of the node's children. 227 | void setChildName(unsigned int uiIndex, const std::string& strNewName); // EXPORT 228 | /// Sets the Name value of one of the node's children. 229 | void setOffsetToChildName(unsigned int uiIndex, dword dwNewOffset); // EXPORT 230 | /// Sets the OffsetToData value of one of the node's children. 231 | void setOffsetToChildData(unsigned int uiIndex, dword dwNewOffset); // EXPORT 232 | 233 | /// Returns the node's Characteristics value. 234 | dword getCharacteristics() const; // EXPORT 235 | /// Returns the node's TimeDateStamp value. 236 | dword getTimeDateStamp() const; // EXPORT 237 | /// Returns the node's MajorVersion value. 238 | word getMajorVersion() const; // EXPORT 239 | /// Returns the node's MinorVersion value. 240 | word getMinorVersion() const; // EXPORT 241 | /// Returns the node's NumberOfNamedEntries value. 242 | word getNumberOfNamedEntries() const; // EXPORT 243 | /// Returns the node's NumberOfIdEntries value. 244 | word getNumberOfIdEntries() const; // EXPORT 245 | 246 | /// Sets the node's Characteristics value. 247 | void setCharacteristics(dword value); // EXPORT 248 | /// Sets the node's TimeDateStamp value. 249 | void setTimeDateStamp(dword value); // EXPORT 250 | /// Sets the node's MajorVersion value. 251 | void setMajorVersion(word value); // EXPORT 252 | /// Sets the node's MinorVersion value. 253 | void setMinorVersion(word value); // EXPORT 254 | /// Sets the node's NumberOfNamedEntries value. 255 | void setNumberOfNamedEntries(word value); // EXPORT 256 | /// Sets the node's NumberOfIdEntries value. 257 | void setNumberOfIdEntries(word value); // EXPORT 258 | 259 | /// Returns the size of a resource node. 260 | // unsigned int size() const; 261 | 262 | /// Constructor 263 | ResourceNode(); 264 | /// Destructor 265 | virtual ~ResourceNode() override; 266 | }; 267 | 268 | /// Auxiliary functor which is used to search through the resource tree. 269 | /** 270 | * Traits class for the template functions of ResourceDirectory. 271 | * It's used to find out which function to use when searching for resource nodes or resource leafs 272 | * in a node's children vector. 273 | **/ 274 | template 275 | struct ResComparer 276 | { 277 | /// Pointer to a member function of ResourceChild 278 | typedef bool(ResourceChild::*CompFunc)(T) const; 279 | 280 | /// Return 0 for all unspecialized versions of ResComparer. 281 | static CompFunc comp(); 282 | }; 283 | 284 | /// Auxiliary functor which is used to search through the resource tree. 285 | /** 286 | * ResComparer is used when a resource element is searched for by ID. 287 | **/ 288 | template<> 289 | struct ResComparer 290 | { 291 | /// Pointer to a member function of ResourceChild 292 | typedef bool(ResourceChild::*CompFunc)(dword) const; 293 | 294 | /// Return the address of the ResourceChild member function that compares the ids of resource elements. 295 | static CompFunc comp() 296 | { 297 | return &ResourceChild::equalId; 298 | } 299 | }; 300 | 301 | /// Auxiliary functor which is used to search through the resource tree. 302 | /** 303 | * This specializd version of ResComparer is used when a resource element is searched for by name. 304 | **/ 305 | template<> 306 | struct ResComparer 307 | { 308 | /// Pointer to a member function of ResourceChild 309 | typedef bool(ResourceChild::*CompFunc)(std::string) const; 310 | 311 | /// Return the address of the ResourceChild member function that compares the names of resource elements. 312 | static CompFunc comp() 313 | { 314 | return &ResourceChild::equalName; 315 | } 316 | }; 317 | 318 | /// Unspecialized function that's used as base template for the specialized versions below. 319 | template 320 | struct fixNumberOfEntries 321 | { 322 | /// Fixes a resource node's header. 323 | static void fix(ResourceNode*); 324 | }; 325 | 326 | /// Fixes NumberOfIdEntries value of a node. 327 | template<> 328 | struct fixNumberOfEntries 329 | { 330 | /// Fixes a resource node's NumberOfIdEntries value. 331 | static void fix(ResourceNode* node) 332 | { 333 | node->header.NumberOfIdEntries = static_cast( 334 | node->children.size() - std::count_if(node->children.begin(), node->children.end(), 335 | [](const ResourceChild& rc) -> bool 336 | { 337 | return rc.isNamedResource(); 338 | }) 339 | ); 340 | } 341 | }; 342 | 343 | /// Fixes NumberOfNamedEntries value of a node. 344 | template<> 345 | struct fixNumberOfEntries 346 | { 347 | /// Fixes a resource node's NumberOfNamedEntries value. 348 | static void fix(ResourceNode* node) 349 | { 350 | node->header.NumberOfNamedEntries = static_cast( 351 | std::count_if(node->children.begin(), node->children.end(), 352 | [](const ResourceChild& rc) -> bool 353 | { 354 | return rc.isNamedResource(); 355 | }) 356 | ); 357 | } 358 | }; 359 | 360 | /// Class that represents the resource directory of a PE file. 361 | /** 362 | * The class ResourceDirectory represents the resource directory of a PE file. This class is fundamentally 363 | * different from the other classes of the PeLib library due to the structure of the ResourceDirectory. 364 | * For once, it's possible to manipulate the ResourceDirectory through a set of "high level" functions and 365 | * and through a set of "low level" functions. The "high level" functions are the functions inside the 366 | * ResourceDirectory class with the exception of getRoot.

367 | * getRoot on the other hand is the first "low level" function. Use it to retrieve the root node of the 368 | * resource tree. Then you can traverse through the tree and manipulate individual nodes and leafs 369 | * directly using the functions provided by the classes ResourceNode and ResourceLeaf.

370 | * There's another difference between the ResourceDirectory class and the other PeLib classes, which is 371 | * once again caused by the special structure of the PE resource directory. The nodes of the resource 372 | * tree must be in a certain order. Manipulating the resource tree does not directly sort the nodes 373 | * correctly as this would cause more trouble than it fixes. That means it's your responsibility to 374 | * fix the resource tree after manipulating it. PeLib makes the job easy for you, just call the 375 | * ResourceDirectory::makeValid function.

376 | * You might also wonder why there's no size() function in this class. I did not forget it. It's just 377 | * that it's impossible to calculate the size of the resource directory without rebuilding it. So why 378 | * should PeLib do this if you can do it just as easily by calling rebuild() and then checking the length 379 | * of the returned vector.

380 | * There are also different ways to serialize (rebuild) the resource tree as it's not a fixed structure 381 | * that can easily be minimized like most other PE directories.

382 | * This means it's entirely possible that the resource tree you read from a file differs from the one 383 | * PeLib creates. This might cause a minor issue. The original resource tree might be smaller (due to 384 | * different padding) so it's crucial that you check if there's enough space in the original resource 385 | * directory before you write the rebuilt resource directory back to the file. 386 | **/ 387 | class ResourceDirectory 388 | { 389 | protected: 390 | /// Start offset of directory in file. 391 | unsigned int m_readOffset; 392 | /// The root node of the resource directory. 393 | ResourceNode m_rnRoot; 394 | /// Detection of invalid structure of nodes in directory. 395 | std::set m_resourceNodeOffsets; 396 | /// Stores RVAs which are occupied by this export directory. 397 | std::vector> m_occupiedAddresses; 398 | /// Error detected by the import table parser 399 | LoaderError m_ldrError; 400 | 401 | // Prepare for some crazy syntax below to make Digital Mars happy. 402 | 403 | /// Retrieves an iterator to a specified resource child. 404 | template 405 | std::vector::const_iterator locateResourceT(S restypeid, T resid) const; 406 | 407 | /// Retrieves an iterator to a specified resource child. 408 | template 409 | std::vector::iterator locateResourceT(S restypeid, T resid); 410 | 411 | /// Adds a new resource. 412 | template 413 | int addResourceT(S restypeid, T resid, ResourceChild& rc); 414 | 415 | /// Removes new resource. 416 | template 417 | int removeResourceT(S restypeid, T resid); 418 | 419 | /// Returns the data of a resource. 420 | template 421 | int getResourceDataT(S restypeid, T resid, std::vector& data) const; 422 | 423 | /// Sets the data of a resource. 424 | template 425 | int setResourceDataT(S restypeid, T resid, std::vector& data); 426 | 427 | /// Returns the ID of a resource. 428 | template 429 | dword getResourceIdT(S restypeid, T resid) const; 430 | 431 | /// Sets the ID of a resource. 432 | template 433 | int setResourceIdT(S restypeid, T resid, dword dwNewResId); 434 | 435 | /// Returns the name of a resource. 436 | template 437 | std::string getResourceNameT(S restypeid, T resid) const; 438 | 439 | /// Sets the name of a resource. 440 | template 441 | int setResourceNameT(S restypeid, T resid, std::string strNewResName); 442 | 443 | public: 444 | /// Constructor 445 | ResourceDirectory(); 446 | /// Destructor 447 | virtual ~ResourceDirectory() = default; 448 | 449 | ResourceNode* getRoot(); 450 | const ResourceNode* getRoot() const; 451 | 452 | /// Retrieve the loader error 453 | LoaderError loaderError() const; 454 | void setLoaderError(LoaderError ldrError); 455 | 456 | /// Corrects a erroneous resource directory. 457 | void makeValid(); 458 | /// Rebuilds the resource directory. 459 | void rebuild(std::vector& vBuffer, unsigned int uiRva) const; 460 | /// Recalculate the tree for different RVA 461 | void recalculate(unsigned int& uiNewSize, unsigned int uiNewRva); 462 | /// Returns the size of the rebuilt resource directory. 463 | // unsigned int size() const; 464 | /// Writes the resource directory to a file. 465 | int write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const; 466 | 467 | /// Adds a new resource type. 468 | int addResourceType(dword dwResTypeId); 469 | /// Adds a new resource type. 470 | int addResourceType(const std::string& strResTypeName); 471 | 472 | /// Removes a resource type and all of it's resources. 473 | int removeResourceType(dword dwResTypeId); 474 | /// Removes a resource type and all of it's resources. 475 | int removeResourceType(const std::string& strResTypeName); 476 | 477 | /// Removes a resource type and all of it's resources. 478 | int removeResourceTypeByIndex(unsigned int uiIndex); 479 | 480 | /// Adds a new resource. 481 | int addResource(dword dwResTypeId, dword dwResId); 482 | /// Adds a new resource. 483 | int addResource(dword dwResTypeId, const std::string& strResName); 484 | /// Adds a new resource. 485 | int addResource(const std::string& strResTypeName, dword dwResId); 486 | /// Adds a new resource. 487 | int addResource(const std::string& strResTypeName, const std::string& strResName); 488 | 489 | /// Removes a resource. 490 | int removeResource(dword dwResTypeId, dword dwResId); 491 | /// Removes a resource. 492 | int removeResource(dword dwResTypeId, const std::string& strResName); 493 | /// Removes a resource. 494 | int removeResource(const std::string& strResTypeName, dword dwResId); 495 | /// Removes a resource. 496 | int removeResource(const std::string& strResTypeName, const std::string& strResName); 497 | 498 | /// Returns start offset of resource directory in file. 499 | unsigned int getOffset() const; 500 | 501 | /// Returns the number of resource types. 502 | unsigned int getNumberOfResourceTypes() const; 503 | 504 | /// Returns the ID of a resource type. 505 | dword getResourceTypeIdByIndex(unsigned int uiIndex) const; 506 | /// Returns the name of a resource type. 507 | std::string getResourceTypeNameByIndex(unsigned int uiIndex) const; 508 | 509 | /// Converts a resource type ID to an index. 510 | int resourceTypeIdToIndex(dword dwResTypeId) const; 511 | /// Converts a resource type name to an index. 512 | int resourceTypeNameToIndex(const std::string& strResTypeName) const; 513 | 514 | /// Returns the number of resources of a certain resource type. 515 | unsigned int getNumberOfResources(dword dwId) const; 516 | /// Returns the number of resources of a certain resource type. 517 | unsigned int getNumberOfResources(const std::string& strResTypeName) const; 518 | 519 | /// Returns the number of resources of a certain resource type. 520 | unsigned int getNumberOfResourcesByIndex(unsigned int uiIndex) const; 521 | 522 | /// Returns the data of a certain resource. 523 | void getResourceData(dword dwResTypeId, dword dwResId, std::vector& data) const; 524 | /// Returns the data of a certain resource. 525 | void getResourceData(dword dwResTypeId, const std::string& strResName, std::vector& data) const; 526 | /// Returns the data of a certain resource. 527 | void getResourceData(const std::string& strResTypeName, dword dwResId, std::vector& data) const; 528 | /// Returns the data of a certain resource. 529 | void getResourceData(const std::string& strResTypeName, const std::string& strResName, std::vector& data) const; 530 | 531 | /// Returns the data of a certain resource. 532 | void getResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector& data) const; 533 | 534 | /// Sets the data of a certain resource. 535 | void setResourceData(dword dwResTypeId, dword dwResId, std::vector& data); 536 | /// Sets the data of a certain resource. 537 | void setResourceData(dword dwResTypeId, const std::string& strResName, std::vector& data); 538 | /// Sets the data of a certain resource. 539 | void setResourceData(const std::string& strResTypeName, dword dwResId, std::vector& data); 540 | /// Sets the data of a certain resource. 541 | void setResourceData(const std::string& strResTypeName, const std::string& strResName, std::vector& data); 542 | 543 | /// Sets the data of a certain resource. 544 | void setResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector& data); 545 | 546 | /// Returns the ID of a certain resource. 547 | dword getResourceId(dword dwResTypeId, const std::string& strResName) const; 548 | /// Returns the ID of a certain resource. 549 | dword getResourceId(const std::string& strResTypeName, const std::string& strResName) const; 550 | 551 | /// Returns the ID of a certain resource. 552 | dword getResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const; 553 | 554 | /// Sets the ID of a certain resource. 555 | void setResourceId(dword dwResTypeId, dword dwResId, dword dwNewResId); 556 | /// Sets the ID of a certain resource. 557 | void setResourceId(dword dwResTypeId, const std::string& strResName, dword dwNewResId); 558 | /// Sets the ID of a certain resource. 559 | void setResourceId(const std::string& strResTypeName, dword dwResId, dword dwNewResId); 560 | /// Sets the ID of a certain resource. 561 | void setResourceId(const std::string& strResTypeName, const std::string& strResName, dword dwNewResId); 562 | 563 | /// Sets the ID of a certain resource. 564 | void setResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, dword dwNewResId); 565 | 566 | /// Returns the name of a certain resource. 567 | std::string getResourceName(dword dwResTypeId, dword dwResId) const; 568 | /// Returns the name of a certain resource. 569 | std::string getResourceName(const std::string& strResTypeName, dword dwResId) const; 570 | 571 | /// Returns the name of a certain resource. 572 | std::string getResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const; 573 | 574 | /// Sets the name of a certain resource. 575 | void setResourceName(dword dwResTypeId, dword dwResId, const std::string& strNewResName); 576 | /// Sets the name of a certain resource. 577 | void setResourceName(dword dwResTypeId, const std::string& strResName, const std::string& strNewResName); 578 | /// Sets the name of a certain resource. 579 | void setResourceName(const std::string& strResTypeName, dword dwResId, const std::string& strNewResName); 580 | /// Sets the name of a certain resource. 581 | void setResourceName(const std::string& strResTypeName, const std::string& strResName, const std::string& strNewResName); 582 | 583 | /// Sets the name of a certain resource. 584 | void setResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, const std::string& strNewResName); 585 | 586 | /// Insert offset of loaded node. 587 | void insertNodeOffset(std::size_t nodeOffset); 588 | /// Check if node with specified offset was loaded. 589 | bool hasNodeOffset(std::size_t nodeOffset) const; 590 | 591 | void addOccupiedAddressRange(unsigned int start, unsigned int end); 592 | const std::vector>& getOccupiedAddresses() const; 593 | }; 594 | 595 | /** 596 | * Looks through the entire resource tree and returns a const_iterator to the resource specified 597 | * by the parameters. 598 | * @param restypeid Identifier of the resource type (either ID or name). 599 | * @param resid Identifier of the resource (either ID or name). 600 | * @return A const_iterator to the specified resource. 601 | **/ 602 | template 603 | std::vector::const_iterator ResourceDirectory::locateResourceT(S restypeid, T resid) const 604 | { 605 | typedef bool(ResourceChild::*CompFunc1)(S) const; 606 | typedef bool(ResourceChild::*CompFunc2)(T) const; 607 | 608 | CompFunc1 comp1 = ResComparer::comp(); 609 | CompFunc2 comp2 = ResComparer::comp(); 610 | 611 | std::vector::const_iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); 612 | if (Iter == m_rnRoot.children.end()) 613 | { 614 | return Iter; 615 | } 616 | 617 | ResourceNode* currNode = static_cast(Iter->child); 618 | std::vector::const_iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); 619 | if (ResIter == currNode->children.end()) 620 | { 621 | return ResIter; 622 | } 623 | 624 | return ResIter; 625 | } 626 | 627 | /** 628 | * Looks through the entire resource tree and returns an iterator to the resource specified 629 | * by the parameters. 630 | * @param restypeid Identifier of the resource type (either ID or name). 631 | * @param resid Identifier of the resource (either ID or name). 632 | * @return An iterator to the specified resource. 633 | **/ 634 | template 635 | std::vector::iterator ResourceDirectory::locateResourceT(S restypeid, T resid) 636 | { 637 | typedef bool(ResourceChild::*CompFunc1)(S) const; 638 | typedef bool(ResourceChild::*CompFunc2)(T) const; 639 | 640 | CompFunc1 comp1 = ResComparer::comp(); 641 | CompFunc2 comp2 = ResComparer::comp(); 642 | 643 | std::vector::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); 644 | if (Iter == m_rnRoot.children.end()) 645 | { 646 | return Iter; 647 | } 648 | 649 | ResourceNode* currNode = static_cast(Iter->child); 650 | std::vector::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); 651 | if (ResIter == currNode->children.end()) 652 | { 653 | return ResIter; 654 | } 655 | 656 | return ResIter; 657 | } 658 | 659 | /** 660 | * Adds a new resource, resource type and ID are specified by the parameters. 661 | * @param restypeid Identifier of the resource type (either ID or name). 662 | * @param resid Identifier of the resource (either ID or name). 663 | * @param rc ResourceChild that will be added. 664 | **/ 665 | template 666 | int ResourceDirectory::addResourceT(S restypeid, T resid, ResourceChild& rc) 667 | { 668 | typedef bool(ResourceChild::*CompFunc1)(S) const; 669 | typedef bool(ResourceChild::*CompFunc2)(T) const; 670 | 671 | CompFunc1 comp1 = ResComparer::comp(); 672 | CompFunc2 comp2 = ResComparer::comp(); 673 | 674 | std::vector::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); 675 | if (Iter == m_rnRoot.children.end()) 676 | { 677 | return ERROR_ENTRY_NOT_FOUND; 678 | // throw Exceptions::ResourceTypeDoesNotExist(ResourceDirectoryId, __LINE__); 679 | } 680 | 681 | ResourceNode* currNode = static_cast(Iter->child); 682 | std::vector::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); 683 | if (ResIter != currNode->children.end()) 684 | { 685 | return ERROR_DUPLICATE_ENTRY; 686 | // throw Exceptions::EntryAlreadyExists(ResourceDirectoryId, __LINE__); 687 | } 688 | 689 | rc.child = new ResourceNode; 690 | ResourceChild rlnew; 691 | rlnew.child = new ResourceLeaf; 692 | ResourceNode* currNode2 = static_cast(rc.child); 693 | currNode2->children.push_back(rlnew); 694 | currNode->children.push_back(rc); 695 | 696 | fixNumberOfEntries::fix(currNode); 697 | fixNumberOfEntries::fix(currNode2); 698 | 699 | return ERROR_NONE; 700 | } 701 | 702 | /** 703 | * Removes a resource, resource type and ID are specified by the parameters. 704 | * @param restypeid Identifier of the resource type (either ID or name). 705 | * @param resid Identifier of the resource (either ID or name). 706 | **/ 707 | template 708 | int ResourceDirectory::removeResourceT(S restypeid, T resid) 709 | { 710 | typedef bool(ResourceChild::*CompFunc1)(S) const; 711 | typedef bool(ResourceChild::*CompFunc2)(T) const; 712 | 713 | CompFunc1 comp1 = ResComparer::comp(); 714 | CompFunc2 comp2 = ResComparer::comp(); 715 | 716 | std::vector::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); 717 | if (Iter == m_rnRoot.children.end()) 718 | { 719 | return ERROR_ENTRY_NOT_FOUND; 720 | //throw Exceptions::ResourceTypeDoesNotExist(ResourceDirectoryId, __LINE__); 721 | } 722 | 723 | ResourceNode* currNode = static_cast(Iter->child); 724 | std::vector::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); 725 | if (ResIter == currNode->children.end()) 726 | { 727 | return ERROR_ENTRY_NOT_FOUND; 728 | // throw Exceptions::InvalidName(ResourceDirectoryId, __LINE__); 729 | } 730 | 731 | currNode->children.erase(ResIter); 732 | 733 | fixNumberOfEntries::fix(currNode); 734 | 735 | return ERROR_NONE; 736 | } 737 | 738 | /** 739 | * Returns the data of a resource, resource type and ID are specified by the parameters. 740 | * @param restypeid Identifier of the resource type (either ID or name). 741 | * @param resid Identifier of the resource (either ID or name). 742 | * @param data The data of the resource will be written into this vector. 743 | **/ 744 | template 745 | int ResourceDirectory::getResourceDataT(S restypeid, T resid, std::vector& data) const 746 | { 747 | std::vector::const_iterator ResIter = locateResourceT(restypeid, resid); 748 | ResourceNode* currNode = static_cast(ResIter->child); 749 | ResourceLeaf* currLeaf = static_cast(currNode->children[0].child); 750 | data.assign(currLeaf->m_data.begin(), currLeaf->m_data.end()); 751 | 752 | return ERROR_NONE; 753 | } 754 | 755 | /** 756 | * Sets the data of a resource, resource type and ID are specified by the parameters. 757 | * @param restypeid Identifier of the resource type (either ID or name). 758 | * @param resid Identifier of the resource (either ID or name). 759 | * @param data The new data of the resource is taken from this vector. 760 | **/ 761 | template 762 | int ResourceDirectory::setResourceDataT(S restypeid, T resid, std::vector& data) 763 | { 764 | std::vector::iterator ResIter = locateResourceT(restypeid, resid); 765 | ResourceNode* currNode = static_cast(ResIter->child); 766 | ResourceLeaf* currLeaf = static_cast(currNode->children[0].child); 767 | currLeaf->m_data.assign(data.begin(), data.end()); 768 | 769 | return ERROR_NONE; 770 | } 771 | 772 | /** 773 | * Returns the id of a resource, resource type and ID are specified by the parameters. 774 | * Note: Calling this function with resid == the ID of the resource makes no sense at all. 775 | * @param restypeid Identifier of the resource type (either ID or name). 776 | * @param resid Identifier of the resource (either ID or name). 777 | * @return The ID of the specified resource. 778 | **/ 779 | template 780 | dword ResourceDirectory::getResourceIdT(S restypeid, T resid) const 781 | { 782 | std::vector::const_iterator ResIter = locateResourceT(restypeid, resid); 783 | return ResIter->entry.irde.Name; 784 | } 785 | 786 | /** 787 | * Sets the id of a resource, resource type and ID are specified by the parameters. 788 | * @param restypeid Identifier of the resource type (either ID or name). 789 | * @param resid Identifier of the resource (either ID or name). 790 | * @param dwNewResId New ID of the resource. 791 | **/ 792 | template 793 | int ResourceDirectory::setResourceIdT(S restypeid, T resid, dword dwNewResId) 794 | { 795 | std::vector::iterator ResIter = locateResourceT(restypeid, resid); 796 | ResIter->entry.irde.Name = dwNewResId; 797 | return ERROR_NONE; 798 | } 799 | 800 | /** 801 | * Returns the name of a resource, resource type and ID are specified by the parameters. 802 | * Note: Calling this function with resid == the name of the resource makes no sense at all. 803 | * @param restypeid Identifier of the resource type (either ID or name). 804 | * @param resid Identifier of the resource (either ID or name). 805 | * @return The name of the specified resource. 806 | **/ 807 | template 808 | std::string ResourceDirectory::getResourceNameT(S restypeid, T resid) const 809 | { 810 | std::vector::const_iterator ResIter = locateResourceT(restypeid, resid); 811 | return ResIter->entry.wstrName; 812 | } 813 | 814 | /** 815 | * Sets the name of a resource, resource type and ID are specified by the parameters. 816 | * @param restypeid Identifier of the resource type (either ID or name). 817 | * @param resid Identifier of the resource (either ID or name). 818 | * @param strNewResName The new name of the resource. 819 | **/ 820 | template 821 | int ResourceDirectory::setResourceNameT(S restypeid, T resid, std::string strNewResName) 822 | { 823 | std::vector::iterator ResIter = locateResourceT(restypeid, resid); 824 | ResIter->entry.wstrName = strNewResName; 825 | 826 | return ERROR_NONE; 827 | } 828 | 829 | template 830 | class ResourceDirectoryT : public ResourceDirectory 831 | { 832 | public: 833 | /// Reads the resource directory from a file. 834 | int read(std::istream& inStream, const PeHeaderT& peHeader); 835 | }; 836 | 837 | /** 838 | * Reads the resource directory from a file. 839 | * @param inStream Input stream. 840 | * @param peHeader A valid PE header which is necessary because some RVA 841 | * calculations need to be done. 842 | **/ 843 | template 844 | int ResourceDirectoryT::read( 845 | std::istream& inStream, 846 | const PeHeaderT& peHeader) 847 | { 848 | unsigned int uiResDirRva = peHeader.getIddResourceRva(); 849 | unsigned int uiOffset = peHeader.rvaToOffset(uiResDirRva); 850 | 851 | m_resourceNodeOffsets.clear(); 852 | m_readOffset = uiOffset; 853 | if (!uiOffset) 854 | { 855 | return ERROR_INVALID_FILE; 856 | } 857 | 858 | IStreamWrapper inStream_w(inStream); 859 | 860 | if (!inStream_w) 861 | { 862 | return ERROR_OPENING_FILE; 863 | } 864 | 865 | std::uint64_t ulFileSize = fileSize(inStream_w); 866 | if (ulFileSize < uiOffset) 867 | { 868 | return ERROR_INVALID_FILE; 869 | } 870 | 871 | inStream_w.seekg(uiOffset, std::ios::beg); 872 | 873 | return m_rnRoot.read(inStream_w, uiOffset, 0, uiResDirRva, ulFileSize, peHeader.getSizeOfImage(), this); 874 | } 875 | } 876 | 877 | #endif 878 | -------------------------------------------------------------------------------- /src/graphics/resource.h: -------------------------------------------------------------------------------- 1 | 2 | /* ------------------- Resource Compiler Header File -------------------- */ 3 | 4 | /* This file supplies the constants used by the resource compiler for 5 | various 32 bit resource components in .RC script files. */ 6 | 7 | /* ---------------------------------------------------------------------- */ 8 | 9 | #define WM_DDE_FIRST 0x03E0 10 | #define WM_DDE_INITIATE (WM_DDE_FIRST) 11 | #define WM_DDE_TERMINATE (WM_DDE_FIRST+1) 12 | #define WM_DDE_ADVISE (WM_DDE_FIRST+2) 13 | #define WM_DDE_UNADVISE (WM_DDE_FIRST+3) 14 | #define WM_DDE_ACK (WM_DDE_FIRST+4) 15 | #define WM_DDE_DATA (WM_DDE_FIRST+5) 16 | #define WM_DDE_REQUEST (WM_DDE_FIRST+6) 17 | #define WM_DDE_POKE (WM_DDE_FIRST+7) 18 | #define WM_DDE_EXECUTE (WM_DDE_FIRST+8) 19 | #define WM_DDE_LAST (WM_DDE_FIRST+8) 20 | 21 | #define HDS_HORZ 0x0000 22 | #define HDS_BUTTONS 0x0002 23 | #define HDS_HOTTRACK 0x0004 24 | #define HDS_HIDDEN 0x0008 25 | #define HDS_DRAGDROP 0x0040 26 | #define HDS_FULLDRAG 0x0080 27 | #define RBS_TOOLTIPS 0x0100 28 | #define RBS_VARHEIGHT 0x0200 29 | #define RBS_BANDBORDERS 0x0400 30 | #define RBS_FIXEDORDER 0x0800 31 | #define RBS_REGISTERDROP 0x1000 32 | #define RBS_AUTOSIZE 0x2000 33 | #define RBS_VERTICALGRIPPER 0x4000 34 | #define RBS_DBLCLKTOGGLE 0x8000 35 | 36 | #define TTS_ALWAYSTIP 0x01 37 | #define TTS_NOPREFIX 0x02 38 | 39 | #define SBARS_SIZEGRIP 0x0100 40 | 41 | #define TBS_AUTOTICKS 0x0001 42 | #define TBS_VERT 0x0002 43 | #define TBS_HORZ 0x0000 44 | #define TBS_TOP 0x0004 45 | #define TBS_BOTTOM 0x0000 46 | #define TBS_LEFT 0x0004 47 | #define TBS_RIGHT 0x0000 48 | #define TBS_BOTH 0x0008 49 | #define TBS_NOTICKS 0x0010 50 | #define TBS_ENABLESELRANGE 0x0020 51 | #define TBS_FIXEDLENGTH 0x0040 52 | #define TBS_NOTHUMB 0x0080 53 | #define TBS_TOOLTIPS 0x0100 54 | 55 | #define UDS_WRAP 0x0001 56 | #define UDS_SETBUDDYINT 0x0002 57 | #define UDS_ALIGNRIGHT 0x0004 58 | #define UDS_ALIGNLEFT 0x0008 59 | #define UDS_AUTOBUDDY 0x0010 60 | #define UDS_ARROWKEYS 0x0020 61 | #define UDS_HORZ 0x0040 62 | #define UDS_NOTHOUSANDS 0x0080 63 | #define UDS_HOTTRACK 0x0100 64 | 65 | #define PBS_SMOOTH 0x01 66 | #define PBS_VERTICAL 0x04 67 | 68 | /* --------------------- Common Control Styles ------------------------- */ 69 | 70 | #define CCS_TOP 0x00000001L 71 | #define CCS_NOMOVEY 0x00000002L 72 | #define CCS_BOTTOM 0x00000003L 73 | #define CCS_NORESIZE 0x00000004L 74 | #define CCS_NOPARENTALIGN 0x00000008L 75 | #define CCS_ADJUSTABLE 0x00000020L 76 | #define CCS_NODIVIDER 0x00000040L 77 | #define CCS_VERT 0x00000080L 78 | #define CCS_LEFT (CCS_VERT | CCS_TOP) 79 | #define CCS_RIGHT (CCS_VERT | CCS_BOTTOM) 80 | #define CCS_NOMOVEX (CCS_VERT | CCS_NOMOVEY) 81 | 82 | #define LVS_ICON 0x0000 83 | #define LVS_REPORT 0x0001 84 | #define LVS_SMALLICON 0x0002 85 | #define LVS_LIST 0x0003 86 | #define LVS_TYPEMASK 0x0003 87 | #define LVS_SINGLESEL 0x0004 88 | #define LVS_SHOWSELALWAYS 0x0008 89 | #define LVS_SORTASCENDING 0x0010 90 | #define LVS_SORTDESCENDING 0x0020 91 | #define LVS_SHAREIMAGELISTS 0x0040 92 | #define LVS_NOLABELWRAP 0x0080 93 | #define LVS_AUTOARRANGE 0x0100 94 | #define LVS_EDITLABELS 0x0200 95 | #define LVS_OWNERDATA 0x1000 96 | #define LVS_NOSCROLL 0x2000 97 | #define LVS_TYPESTYLEMASK 0xfc00 98 | #define LVS_ALIGNTOP 0x0000 99 | #define LVS_ALIGNLEFT 0x0800 100 | #define LVS_ALIGNMASK 0x0c00 101 | #define LVS_OWNERDRAWFIXED 0x0400 102 | #define LVS_NOCOLUMNHEADER 0x4000 103 | #define LVS_NOSORTHEADER 0x8000 104 | #define TVS_HASBUTTONS 0x0001 105 | #define TVS_HASLINES 0x0002 106 | #define TVS_LINESATROOT 0x0004 107 | #define TVS_EDITLABELS 0x0008 108 | #define TVS_DISABLEDRAGDROP 0x0010 109 | #define TVS_SHOWSELALWAYS 0x0020 110 | #define TVS_RTLREADING 0x0040 111 | #define TVS_NOTOOLTIPS 0x0080 112 | #define TVS_CHECKBOXES 0x0100 113 | #define TVS_TRACKSELECT 0x0200 114 | #define TVS_SINGLEEXPAND 0x0400 115 | #define TVS_INFOTIP 0x0800 116 | #define TVS_FULLROWSELECT 0x1000 117 | #define TVS_NOSCROLL 0x2000 118 | #define TVS_NONEVENHEIGHT 0x4000 119 | 120 | #define TCS_SCROLLOPPOSITE 0x0001 121 | #define TCS_BOTTOM 0x0002 122 | #define TCS_RIGHT 0x0002 123 | #define TCS_MULTISELECT 0x0004 124 | #define TCS_FLATBUTTONS 0x0008 125 | #define TCS_FORCEICONLEFT 0x0010 126 | #define TCS_FORCELABELLEFT 0x0020 127 | #define TCS_HOTTRACK 0x0040 128 | #define TCS_VERTICAL 0x0080 129 | #define TCS_TABS 0x0000 130 | #define TCS_BUTTONS 0x0100 131 | #define TCS_SINGLELINE 0x0000 132 | #define TCS_MULTILINE 0x0200 133 | #define TCS_RIGHTJUSTIFY 0x0000 134 | #define TCS_FIXEDWIDTH 0x0400 135 | #define TCS_RAGGEDRIGHT 0x0800 136 | #define TCS_FOCUSONBUTTONDOWN 0x1000 137 | #define TCS_OWNERDRAWFIXED 0x2000 138 | #define TCS_TOOLTIPS 0x4000 139 | #define TCS_FOCUSNEVER 0x8000 140 | 141 | #define ACS_CENTER 0x0001 142 | #define ACS_TRANSPARENT 0x0002 143 | #define ACS_AUTOPLAY 0x0004 144 | #define ACS_TIMER 0x0008 145 | 146 | #define DTS_UPDOWN 0x0001 147 | #define DTS_SHOWNONE 0x0002 148 | #define DTS_SHORTDATEFORMAT 0x0000 149 | #define DTS_LONGDATEFORMAT 0x0004 150 | #define DTS_TIMEFORMAT 0x0009 151 | #define DTS_APPCANPARSE 0x0010 152 | #define DTS_RIGHTALIGN 0x0020 153 | 154 | #define PGS_VERT 0x00000000 155 | #define PGS_HORZ 0x00000001 156 | #define PGS_AUTOSCROLL 0x00000002 157 | #define PGS_DRAGNDROP 0x00000004 158 | 159 | /* style definition */ 160 | 161 | #define NFS_EDIT 0x0001 162 | #define NFS_STATIC 0x0002 163 | #define NFS_LISTCOMBO 0x0004 164 | #define NFS_BUTTON 0x0008 165 | #define NFS_ALL 0x0010 166 | 167 | /* ShowWindow() Commands */ 168 | 169 | #define SW_HIDE 0 170 | #define SW_SHOWNORMAL 1 171 | #define SW_NORMAL 1 172 | #define SW_SHOWMINIMIZED 2 173 | #define SW_SHOWMAXIMIZED 3 174 | #define SW_MAXIMIZE 3 175 | #define SW_SHOWNOACTIVATE 4 176 | #define SW_SHOW 5 177 | #define SW_MINIMIZE 6 178 | #define SW_SHOWMINNOACTIVE 7 179 | #define SW_SHOWNA 8 180 | #define SW_RESTORE 9 181 | #define SW_SHOWDEFAULT 10 182 | #define SW_FORCEMINIMIZE 11 183 | #define SW_MAX 11 184 | 185 | /* 186 | * Old ShowWindow() Commands 187 | */ 188 | #define HIDE_WINDOW 0 189 | #define SHOW_OPENWINDOW 1 190 | #define SHOW_ICONWINDOW 2 191 | #define SHOW_FULLSCREEN 3 192 | #define SHOW_OPENNOACTIVATE 4 193 | 194 | /* 195 | * Identifiers for the WM_SHOWWINDOW message 196 | */ 197 | #define SW_PARENTCLOSING 1 198 | #define SW_OTHERZOOM 2 199 | #define SW_PARENTOPENING 3 200 | #define SW_OTHERUNZOOM 4 201 | 202 | /* 203 | * Virtual Keys, Standard Set 204 | */ 205 | #define VK_LBUTTON 0x01 206 | #define VK_RBUTTON 0x02 207 | #define VK_CANCEL 0x03 208 | #define VK_MBUTTON 0x04 209 | 210 | #define VK_BACK 0x08 211 | #define VK_TAB 0x09 212 | 213 | #define VK_CLEAR 0x0C 214 | #define VK_RETURN 0x0D 215 | 216 | #define VK_SHIFT 0x10 217 | #define VK_CONTROL 0x11 218 | #define VK_MENU 0x12 219 | #define VK_PAUSE 0x13 220 | #define VK_CAPITAL 0x14 221 | 222 | #define VK_KANA 0x15 223 | #define VK_HANGEUL 0x15 224 | #define VK_HANGUL 0x15 225 | #define VK_JUNJA 0x17 226 | #define VK_FINAL 0x18 227 | #define VK_HANJA 0x19 228 | #define VK_KANJI 0x19 229 | 230 | #define VK_ESCAPE 0x1B 231 | 232 | #define VK_CONVERT 0x1C 233 | #define VK_NONCONVERT 0x1D 234 | #define VK_ACCEPT 0x1E 235 | #define VK_MODECHANGE 0x1F 236 | 237 | #define VK_SPACE 0x20 238 | #define VK_PRIOR 0x21 239 | #define VK_NEXT 0x22 240 | #define VK_END 0x23 241 | #define VK_HOME 0x24 242 | #define VK_LEFT 0x25 243 | #define VK_UP 0x26 244 | #define VK_RIGHT 0x27 245 | #define VK_DOWN 0x28 246 | #define VK_SELECT 0x29 247 | #define VK_PRINT 0x2A 248 | #define VK_EXECUTE 0x2B 249 | #define VK_SNAPSHOT 0x2C 250 | #define VK_INSERT 0x2D 251 | #define VK_DELETE 0x2E 252 | #define VK_HELP 0x2F 253 | 254 | /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ 255 | /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ 256 | 257 | #define VK_LWIN 0x5B 258 | #define VK_RWIN 0x5C 259 | #define VK_APPS 0x5D 260 | 261 | #define VK_NUMPAD0 0x60 262 | #define VK_NUMPAD1 0x61 263 | #define VK_NUMPAD2 0x62 264 | #define VK_NUMPAD3 0x63 265 | #define VK_NUMPAD4 0x64 266 | #define VK_NUMPAD5 0x65 267 | #define VK_NUMPAD6 0x66 268 | #define VK_NUMPAD7 0x67 269 | #define VK_NUMPAD8 0x68 270 | #define VK_NUMPAD9 0x69 271 | #define VK_MULTIPLY 0x6A 272 | #define VK_ADD 0x6B 273 | #define VK_SEPARATOR 0x6C 274 | #define VK_SUBTRACT 0x6D 275 | #define VK_DECIMAL 0x6E 276 | #define VK_DIVIDE 0x6F 277 | #define VK_F1 0x70 278 | #define VK_F2 0x71 279 | #define VK_F3 0x72 280 | #define VK_F4 0x73 281 | #define VK_F5 0x74 282 | #define VK_F6 0x75 283 | #define VK_F7 0x76 284 | #define VK_F8 0x77 285 | #define VK_F9 0x78 286 | #define VK_F10 0x79 287 | #define VK_F11 0x7A 288 | #define VK_F12 0x7B 289 | #define VK_F13 0x7C 290 | #define VK_F14 0x7D 291 | #define VK_F15 0x7E 292 | #define VK_F16 0x7F 293 | #define VK_F17 0x80 294 | #define VK_F18 0x81 295 | #define VK_F19 0x82 296 | #define VK_F20 0x83 297 | #define VK_F21 0x84 298 | #define VK_F22 0x85 299 | #define VK_F23 0x86 300 | #define VK_F24 0x87 301 | #define VK_NUMLOCK 0x90 302 | #define VK_SCROLL 0x91 303 | #define VK_LSHIFT 0xA0 304 | #define VK_RSHIFT 0xA1 305 | #define VK_LCONTROL 0xA2 306 | #define VK_RCONTROL 0xA3 307 | #define VK_LMENU 0xA4 308 | #define VK_RMENU 0xA5 309 | #define VK_PROCESSKEY 0xE5 310 | #define VK_ATTN 0xF6 311 | #define VK_CRSEL 0xF7 312 | #define VK_EXSEL 0xF8 313 | #define VK_EREOF 0xF9 314 | #define VK_PLAY 0xFA 315 | #define VK_ZOOM 0xFB 316 | #define VK_NONAME 0xFC 317 | #define VK_PA1 0xFD 318 | #define VK_OEM_CLEAR 0xFE 319 | 320 | #define WM_NULL 0x0000 321 | #define WM_CREATE 0x0001 322 | #define WM_DESTROY 0x0002 323 | #define WM_MOVE 0x0003 324 | #define WM_SIZE 0x0005 325 | #define WM_ACTIVATE 0x0006 326 | 327 | /* WM_ACTIVATE state values */ 328 | 329 | #define WA_INACTIVE 0 330 | #define WA_ACTIVE 1 331 | #define WA_CLICKACTIVE 2 332 | 333 | #define WM_SETFOCUS 0x0007 334 | #define WM_KILLFOCUS 0x0008 335 | #define WM_ENABLE 0x000A 336 | #define WM_SETREDRAW 0x000B 337 | #define WM_SETTEXT 0x000C 338 | #define WM_GETTEXT 0x000D 339 | #define WM_GETTEXTLENGTH 0x000E 340 | #define WM_PAINT 0x000F 341 | #define WM_CLOSE 0x0010 342 | #define WM_QUERYENDSESSION 0x0011 343 | #define WM_QUIT 0x0012 344 | #define WM_QUERYOPEN 0x0013 345 | #define WM_ERASEBKGND 0x0014 346 | #define WM_SYSCOLORCHANGE 0x0015 347 | #define WM_ENDSESSION 0x0016 348 | #define WM_SHOWWINDOW 0x0018 349 | #define WM_WININICHANGE 0x001A 350 | #define WM_SETTINGCHANGE WM_WININICHANGE 351 | 352 | #define WM_DEVMODECHANGE 0x001B 353 | #define WM_ACTIVATEAPP 0x001C 354 | #define WM_FONTCHANGE 0x001D 355 | #define WM_TIMECHANGE 0x001E 356 | #define WM_CANCELMODE 0x001F 357 | #define WM_SETCURSOR 0x0020 358 | #define WM_MOUSEACTIVATE 0x0021 359 | #define WM_CHILDACTIVATE 0x0022 360 | #define WM_QUEUESYNC 0x0023 361 | 362 | #define WM_GETMINMAXINFO 0x0024 363 | #define WM_PAINTICON 0x0026 364 | #define WM_ICONERASEBKGND 0x0027 365 | #define WM_NEXTDLGCTL 0x0028 366 | #define WM_SPOOLERSTATUS 0x002A 367 | #define WM_DRAWITEM 0x002B 368 | #define WM_MEASUREITEM 0x002C 369 | #define WM_DELETEITEM 0x002D 370 | #define WM_VKEYTOITEM 0x002E 371 | #define WM_CHARTOITEM 0x002F 372 | #define WM_SETFONT 0x0030 373 | #define WM_GETFONT 0x0031 374 | #define WM_SETHOTKEY 0x0032 375 | #define WM_GETHOTKEY 0x0033 376 | #define WM_QUERYDRAGICON 0x0037 377 | #define WM_COMPAREITEM 0x0039 378 | #define WM_GETOBJECT 0x003D 379 | #define WM_COMPACTING 0x0041 380 | #define WM_COMMNOTIFY 0x0044 381 | #define WM_WINDOWPOSCHANGING 0x0046 382 | #define WM_WINDOWPOSCHANGED 0x0047 383 | #define WM_POWER 0x0048 384 | 385 | /* wParam for WM_POWER window message and DRV_POWER driver notification */ 386 | 387 | #define PWR_OK 1 388 | #define PWR_FAIL (-1) 389 | #define PWR_SUSPENDREQUEST 1 390 | #define PWR_SUSPENDRESUME 2 391 | #define PWR_CRITICALRESUME 3 392 | 393 | #define WM_COPYDATA 0x004A 394 | #define WM_CANCELJOURNAL 0x004B 395 | 396 | #define WM_NOTIFY 0x004E 397 | #define WM_INPUTLANGCHANGEREQUEST 0x0050 398 | #define WM_INPUTLANGCHANGE 0x0051 399 | #define WM_TCARD 0x0052 400 | #define WM_HELP 0x0053 401 | #define WM_USERCHANGED 0x0054 402 | #define WM_NOTIFYFORMAT 0x0055 403 | 404 | #define NFR_ANSI 1 405 | #define NFR_UNICODE 2 406 | #define NF_QUERY 3 407 | #define NF_REQUERY 4 408 | 409 | #define WM_CONTEXTMENU 0x007B 410 | #define WM_STYLECHANGING 0x007C 411 | #define WM_STYLECHANGED 0x007D 412 | #define WM_DISPLAYCHANGE 0x007E 413 | #define WM_GETICON 0x007F 414 | #define WM_SETICON 0x0080 415 | 416 | #define WM_NCCREATE 0x0081 417 | #define WM_NCDESTROY 0x0082 418 | #define WM_NCCALCSIZE 0x0083 419 | #define WM_NCHITTEST 0x0084 420 | #define WM_NCPAINT 0x0085 421 | #define WM_NCACTIVATE 0x0086 422 | #define WM_GETDLGCODE 0x0087 423 | #define WM_SYNCPAINT 0x0088 424 | #define WM_NCMOUSEMOVE 0x00A0 425 | #define WM_NCLBUTTONDOWN 0x00A1 426 | #define WM_NCLBUTTONUP 0x00A2 427 | #define WM_NCLBUTTONDBLCLK 0x00A3 428 | #define WM_NCRBUTTONDOWN 0x00A4 429 | #define WM_NCRBUTTONUP 0x00A5 430 | #define WM_NCRBUTTONDBLCLK 0x00A6 431 | #define WM_NCMBUTTONDOWN 0x00A7 432 | #define WM_NCMBUTTONUP 0x00A8 433 | #define WM_NCMBUTTONDBLCLK 0x00A9 434 | 435 | #define WM_KEYFIRST 0x0100 436 | #define WM_KEYDOWN 0x0100 437 | #define WM_KEYUP 0x0101 438 | #define WM_CHAR 0x0102 439 | #define WM_DEADCHAR 0x0103 440 | #define WM_SYSKEYDOWN 0x0104 441 | #define WM_SYSKEYUP 0x0105 442 | #define WM_SYSCHAR 0x0106 443 | #define WM_SYSDEADCHAR 0x0107 444 | #define WM_KEYLAST 0x0108 445 | 446 | #define WM_IME_STARTCOMPOSITION 0x010D 447 | #define WM_IME_ENDCOMPOSITION 0x010E 448 | #define WM_IME_COMPOSITION 0x010F 449 | #define WM_IME_KEYLAST 0x010F 450 | 451 | #define WM_INITDIALOG 0x0110 452 | #define WM_COMMAND 0x0111 453 | #define WM_SYSCOMMAND 0x0112 454 | #define WM_TIMER 0x0113 455 | #define WM_HSCROLL 0x0114 456 | #define WM_VSCROLL 0x0115 457 | #define WM_INITMENU 0x0116 458 | #define WM_INITMENUPOPUP 0x0117 459 | #define WM_MENUSELECT 0x011F 460 | #define WM_MENUCHAR 0x0120 461 | #define WM_ENTERIDLE 0x0121 462 | #define WM_MENURBUTTONUP 0x0122 463 | #define WM_MENUDRAG 0x0123 464 | #define WM_MENUGETOBJECT 0x0124 465 | #define WM_UNINITMENUPOPUP 0x0125 466 | #define WM_MENUCOMMAND 0x0126 467 | 468 | #define WM_CTLCOLORMSGBOX 0x0132 469 | #define WM_CTLCOLOREDIT 0x0133 470 | #define WM_CTLCOLORLISTBOX 0x0134 471 | #define WM_CTLCOLORBTN 0x0135 472 | #define WM_CTLCOLORDLG 0x0136 473 | #define WM_CTLCOLORSCROLLBAR 0x0137 474 | #define WM_CTLCOLORSTATIC 0x0138 475 | 476 | #define WM_MOUSEFIRST 0x0200 477 | #define WM_MOUSEMOVE 0x0200 478 | #define WM_LBUTTONDOWN 0x0201 479 | #define WM_LBUTTONUP 0x0202 480 | #define WM_LBUTTONDBLCLK 0x0203 481 | #define WM_RBUTTONDOWN 0x0204 482 | #define WM_RBUTTONUP 0x0205 483 | #define WM_RBUTTONDBLCLK 0x0206 484 | #define WM_MBUTTONDOWN 0x0207 485 | #define WM_MBUTTONUP 0x0208 486 | #define WM_MBUTTONDBLCLK 0x0209 487 | 488 | #define WHEEL_DELTA 120 489 | #define WHEEL_PAGESCROLL (UINT_MAX) 490 | 491 | #define WM_PARENTNOTIFY 0x0210 492 | #define WM_ENTERMENULOOP 0x0211 493 | #define WM_EXITMENULOOP 0x0212 494 | 495 | #define WM_NEXTMENU 0x0213 496 | #define WM_SIZING 0x0214 497 | #define WM_CAPTURECHANGED 0x0215 498 | #define WM_MOVING 0x0216 499 | #define WM_POWERBROADCAST 0x0218 500 | #define WM_DEVICECHANGE 0x0219 501 | #define WM_MDICREATE 0x0220 502 | #define WM_MDIDESTROY 0x0221 503 | #define WM_MDIACTIVATE 0x0222 504 | #define WM_MDIRESTORE 0x0223 505 | #define WM_MDINEXT 0x0224 506 | #define WM_MDIMAXIMIZE 0x0225 507 | #define WM_MDITILE 0x0226 508 | #define WM_MDICASCADE 0x0227 509 | #define WM_MDIICONARRANGE 0x0228 510 | #define WM_MDIGETACTIVE 0x0229 511 | 512 | #define WM_MDISETMENU 0x0230 513 | #define WM_ENTERSIZEMOVE 0x0231 514 | #define WM_EXITSIZEMOVE 0x0232 515 | #define WM_DROPFILES 0x0233 516 | #define WM_MDIREFRESHMENU 0x0234 517 | 518 | #define WM_IME_SETCONTEXT 0x0281 519 | #define WM_IME_NOTIFY 0x0282 520 | #define WM_IME_CONTROL 0x0283 521 | #define WM_IME_COMPOSITIONFULL 0x0284 522 | #define WM_IME_SELECT 0x0285 523 | #define WM_IME_CHAR 0x0286 524 | #define WM_IME_REQUEST 0x0288 525 | #define WM_IME_KEYDOWN 0x0290 526 | #define WM_IME_KEYUP 0x0291 527 | 528 | #define WM_MOUSEHOVER 0x02A1 529 | #define WM_MOUSELEAVE 0x02A3 530 | 531 | #define WM_CUT 0x0300 532 | #define WM_COPY 0x0301 533 | #define WM_PASTE 0x0302 534 | #define WM_CLEAR 0x0303 535 | #define WM_UNDO 0x0304 536 | #define WM_RENDERFORMAT 0x0305 537 | #define WM_RENDERALLFORMATS 0x0306 538 | #define WM_DESTROYCLIPBOARD 0x0307 539 | #define WM_DRAWCLIPBOARD 0x0308 540 | #define WM_PAINTCLIPBOARD 0x0309 541 | #define WM_VSCROLLCLIPBOARD 0x030A 542 | #define WM_SIZECLIPBOARD 0x030B 543 | #define WM_ASKCBFORMATNAME 0x030C 544 | #define WM_CHANGECBCHAIN 0x030D 545 | #define WM_HSCROLLCLIPBOARD 0x030E 546 | #define WM_QUERYNEWPALETTE 0x030F 547 | #define WM_PALETTEISCHANGING 0x0310 548 | #define WM_PALETTECHANGED 0x0311 549 | #define WM_HOTKEY 0x0312 550 | 551 | #define WM_PRINT 0x0317 552 | #define WM_PRINTCLIENT 0x0318 553 | 554 | #define WM_HANDHELDFIRST 0x0358 555 | #define WM_HANDHELDLAST 0x035F 556 | 557 | #define WM_AFXFIRST 0x0360 558 | #define WM_AFXLAST 0x037F 559 | 560 | #define WM_PENWINFIRST 0x0380 561 | #define WM_PENWINLAST 0x038F 562 | #define WM_APP 0x8000 563 | 564 | #define WM_USER 0x0400 565 | 566 | /* wParam for WM_SIZING message */ 567 | 568 | #define WMSZ_LEFT 1 569 | #define WMSZ_RIGHT 2 570 | #define WMSZ_TOP 3 571 | #define WMSZ_TOPLEFT 4 572 | #define WMSZ_TOPRIGHT 5 573 | #define WMSZ_BOTTOM 6 574 | #define WMSZ_BOTTOMLEFT 7 575 | #define WMSZ_BOTTOMRIGHT 8 576 | 577 | /* WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes */ 578 | 579 | #define HTERROR (-2) 580 | #define HTTRANSPARENT (-1) 581 | #define HTNOWHERE 0 582 | #define HTCLIENT 1 583 | #define HTCAPTION 2 584 | #define HTSYSMENU 3 585 | #define HTGROWBOX 4 586 | #define HTSIZE HTGROWBOX 587 | #define HTMENU 5 588 | #define HTHSCROLL 6 589 | #define HTVSCROLL 7 590 | #define HTMINBUTTON 8 591 | #define HTMAXBUTTON 9 592 | #define HTLEFT 10 593 | #define HTRIGHT 11 594 | #define HTTOP 12 595 | #define HTTOPLEFT 13 596 | #define HTTOPRIGHT 14 597 | #define HTBOTTOM 15 598 | #define HTBOTTOMLEFT 16 599 | #define HTBOTTOMRIGHT 17 600 | #define HTBORDER 18 601 | #define HTREDUCE HTMINBUTTON 602 | #define HTZOOM HTMAXBUTTON 603 | #define HTSIZEFIRST HTLEFT 604 | #define HTSIZELAST HTBOTTOMRIGHT 605 | #define HTOBJECT 19 606 | #define HTCLOSE 20 607 | #define HTHELP 21 608 | 609 | #define SMTO_NORMAL 0x0000 610 | #define SMTO_BLOCK 0x0001 611 | #define SMTO_ABORTIFHUNG 0x0002 612 | #define SMTO_NOTIMEOUTIFNOTHUNG 0x0008 613 | 614 | /* WM_MOUSEACTIVATE Return Codes */ 615 | 616 | #define MA_ACTIVATE 1 617 | #define MA_ACTIVATEANDEAT 2 618 | #define MA_NOACTIVATE 3 619 | #define MA_NOACTIVATEANDEAT 4 620 | 621 | /* WM_SETICON / WM_GETICON Type Codes */ 622 | 623 | #define ICON_SMALL 0 624 | #define ICON_BIG 1 625 | 626 | /* WM_SIZE message wParam values */ 627 | 628 | #define SIZE_RESTORED 0 629 | #define SIZE_MINIMIZED 1 630 | #define SIZE_MAXIMIZED 2 631 | #define SIZE_MAXSHOW 3 632 | #define SIZE_MAXHIDE 4 633 | 634 | /* Obsolete constant names */ 635 | 636 | #define SIZENORMAL SIZE_RESTORED 637 | #define SIZEICONIC SIZE_MINIMIZED 638 | #define SIZEFULLSCREEN SIZE_MAXIMIZED 639 | #define SIZEZOOMSHOW SIZE_MAXSHOW 640 | #define SIZEZOOMHIDE SIZE_MAXHIDE 641 | 642 | /* WM_NCCALCSIZE "window valid rect" return values */ 643 | 644 | #define WVR_ALIGNTOP 0x0010 645 | #define WVR_ALIGNLEFT 0x0020 646 | #define WVR_ALIGNBOTTOM 0x0040 647 | #define WVR_ALIGNRIGHT 0x0080 648 | #define WVR_HREDRAW 0x0100 649 | #define WVR_VREDRAW 0x0200 650 | #define WVR_REDRAW (WVR_HREDRAW | \ 651 | WVR_VREDRAW) 652 | 653 | /* Key State Masks for Mouse Messages */ 654 | 655 | #define MK_LBUTTON 0x0001 656 | #define MK_RBUTTON 0x0002 657 | #define MK_SHIFT 0x0004 658 | #define MK_CONTROL 0x0008 659 | #define MK_MBUTTON 0x0010 660 | 661 | #define TME_HOVER 0x00000001 662 | #define TME_LEAVE 0x00000002 663 | #define TME_QUERY 0x40000000 664 | #define TME_CANCEL 0x80000000 665 | 666 | #define HOVER_DEFAULT 0xFFFFFFFF 667 | 668 | /* Window Styles */ 669 | 670 | #define WS_OVERLAPPED 0x00000000L 671 | #define WS_POPUP 0x80000000L 672 | #define WS_CHILD 0x40000000L 673 | #define WS_MINIMIZE 0x20000000L 674 | #define WS_VISIBLE 0x10000000L 675 | #define WS_DISABLED 0x08000000L 676 | #define WS_CLIPSIBLINGS 0x04000000L 677 | #define WS_CLIPCHILDREN 0x02000000L 678 | #define WS_MAXIMIZE 0x01000000L 679 | #define WS_CAPTION 0x00C00000L 680 | #define WS_BORDER 0x00800000L 681 | #define WS_DLGFRAME 0x00400000L 682 | #define WS_VSCROLL 0x00200000L 683 | #define WS_HSCROLL 0x00100000L 684 | #define WS_SYSMENU 0x00080000L 685 | #define WS_THICKFRAME 0x00040000L 686 | #define WS_GROUP 0x00020000L 687 | #define WS_TABSTOP 0x00010000L 688 | 689 | #define WS_MINIMIZEBOX 0x00020000L 690 | #define WS_MAXIMIZEBOX 0x00010000L 691 | 692 | #define WS_TILED WS_OVERLAPPED 693 | #define WS_ICONIC WS_MINIMIZE 694 | #define WS_SIZEBOX WS_THICKFRAME 695 | #define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW 696 | 697 | /* Common Window Styles */ 698 | 699 | #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | \ 700 | WS_CAPTION | \ 701 | WS_SYSMENU | \ 702 | WS_THICKFRAME | \ 703 | WS_MINIMIZEBOX | \ 704 | WS_MAXIMIZEBOX) 705 | 706 | #define WS_POPUPWINDOW (WS_POPUP | \ 707 | WS_BORDER | \ 708 | WS_SYSMENU) 709 | 710 | #define WS_CHILDWINDOW (WS_CHILD) 711 | 712 | /* Extended Window Styles */ 713 | 714 | #define WS_EX_DLGMODALFRAME 0x00000001L 715 | #define WS_EX_NOPARENTNOTIFY 0x00000004L 716 | #define WS_EX_TOPMOST 0x00000008L 717 | #define WS_EX_ACCEPTFILES 0x00000010L 718 | #define WS_EX_TRANSPARENT 0x00000020L 719 | #define WS_EX_MDICHILD 0x00000040L 720 | #define WS_EX_TOOLWINDOW 0x00000080L 721 | #define WS_EX_WINDOWEDGE 0x00000100L 722 | #define WS_EX_CLIENTEDGE 0x00000200L 723 | #define WS_EX_CONTEXTHELP 0x00000400L 724 | #define WS_EX_RIGHT 0x00001000L 725 | #define WS_EX_LEFT 0x00000000L 726 | #define WS_EX_RTLREADING 0x00002000L 727 | #define WS_EX_LTRREADING 0x00000000L 728 | #define WS_EX_LEFTSCROLLBAR 0x00004000L 729 | #define WS_EX_RIGHTSCROLLBAR 0x00000000L 730 | #define WS_EX_CONTROLPARENT 0x00010000L 731 | #define WS_EX_STATICEDGE 0x00020000L 732 | #define WS_EX_APPWINDOW 0x00040000L 733 | #define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE) 734 | #define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST) 735 | 736 | /* Class styles */ 737 | 738 | #define CS_VREDRAW 0x0001 739 | #define CS_HREDRAW 0x0002 740 | #define CS_DBLCLKS 0x0008 741 | #define CS_OWNDC 0x0020 742 | #define CS_CLASSDC 0x0040 743 | #define CS_PARENTDC 0x0080 744 | #define CS_NOCLOSE 0x0200 745 | #define CS_SAVEBITS 0x0800 746 | #define CS_BYTEALIGNCLIENT 0x1000 747 | #define CS_BYTEALIGNWINDOW 0x2000 748 | #define CS_GLOBALCLASS 0x4000 749 | 750 | #define CS_IME 0x00010000 751 | 752 | /* Predefined Clipboard Formats */ 753 | 754 | #define CF_TEXT 1 755 | #define CF_BITMAP 2 756 | #define CF_METAFILEPICT 3 757 | #define CF_SYLK 4 758 | #define CF_DIF 5 759 | #define CF_TIFF 6 760 | #define CF_OEMTEXT 7 761 | #define CF_DIB 8 762 | #define CF_PALETTE 9 763 | #define CF_PENDATA 10 764 | #define CF_RIFF 11 765 | #define CF_WAVE 12 766 | #define CF_UNICODETEXT 13 767 | #define CF_ENHMETAFILE 14 768 | #define CF_HDROP 15 769 | #define CF_LOCALE 16 770 | #define CF_MAX 17 771 | #define CF_OWNERDISPLAY 0x0080 772 | #define CF_DSPTEXT 0x0081 773 | #define CF_DSPBITMAP 0x0082 774 | #define CF_DSPMETAFILEPICT 0x0083 775 | #define CF_DSPENHMETAFILE 0x008E 776 | 777 | /* "Private" formats don't get GlobalFree()'d */ 778 | 779 | #define CF_PRIVATEFIRST 0x0200 780 | #define CF_PRIVATELAST 0x02FF 781 | 782 | /* "GDIOBJ" formats do get DeleteObject()'d */ 783 | 784 | #define CF_GDIOBJFIRST 0x0300 785 | #define CF_GDIOBJLAST 0x03FF 786 | 787 | /* Menu flags for Add/Check/EnableMenuItem() */ 788 | 789 | #define MF_INSERT 0x00000000L 790 | #define MF_CHANGE 0x00000080L 791 | #define MF_APPEND 0x00000100L 792 | #define MF_DELETE 0x00000200L 793 | #define MF_REMOVE 0x00001000L 794 | 795 | #define MF_BYCOMMAND 0x00000000L 796 | #define MF_BYPOSITION 0x00000400L 797 | 798 | #define MF_SEPARATOR 0x00000800L 799 | 800 | #define MF_ENABLED 0x00000000L 801 | #define MF_GRAYED 0x00000001L 802 | #define MF_DISABLED 0x00000002L 803 | 804 | #define MF_UNCHECKED 0x00000000L 805 | #define MF_CHECKED 0x00000008L 806 | #define MF_USECHECKBITMAPS 0x00000200L 807 | 808 | #define MF_STRING 0x00000000L 809 | #define MF_BITMAP 0x00000004L 810 | #define MF_OWNERDRAW 0x00000100L 811 | 812 | #define MF_POPUP 0x00000010L 813 | #define MF_MENUBARBREAK 0x00000020L 814 | #define MF_MENUBREAK 0x00000040L 815 | 816 | #define MF_UNHILITE 0x00000000L 817 | #define MF_HILITE 0x00000080L 818 | 819 | #define MF_DEFAULT 0x00001000L 820 | #define MF_SYSMENU 0x00002000L 821 | #define MF_HELP 0x00004000L 822 | #define MF_RIGHTJUSTIFY 0x00004000L 823 | 824 | #define MF_MOUSESELECT 0x00008000L 825 | #define MF_END 0x00000080L 826 | 827 | #define MFT_STRING MF_STRING 828 | #define MFT_BITMAP MF_BITMAP 829 | #define MFT_MENUBARBREAK MF_MENUBARBREAK 830 | #define MFT_MENUBREAK MF_MENUBREAK 831 | #define MFT_OWNERDRAW MF_OWNERDRAW 832 | #define MFT_RADIOCHECK 0x00000200L 833 | #define MFT_SEPARATOR MF_SEPARATOR 834 | #define MFT_RIGHTORDER 0x00002000L 835 | #define MFT_RIGHTJUSTIFY MF_RIGHTJUSTIFY 836 | 837 | /* Menu flags for Add/Check/EnableMenuItem() */ 838 | 839 | #define MFS_GRAYED 0x00000003L 840 | #define MFS_DISABLED MFS_GRAYED 841 | #define MFS_CHECKED MF_CHECKED 842 | #define MFS_HILITE MF_HILITE 843 | #define MFS_ENABLED MF_ENABLED 844 | #define MFS_UNCHECKED MF_UNCHECKED 845 | #define MFS_UNHILITE MF_UNHILITE 846 | #define MFS_DEFAULT MF_DEFAULT 847 | #define MFS_MASK 0x0000108BL 848 | #define MFS_HOTTRACKDRAWN 0x10000000L 849 | #define MFS_CACHEDBMP 0x20000000L 850 | #define MFS_BOTTOMGAPDROP 0x40000000L 851 | #define MFS_TOPGAPDROP 0x80000000L 852 | #define MFS_GAPDROP 0xC0000000L 853 | 854 | #define MF_END 0x00000080L 855 | 856 | /* System Menu Command Values */ 857 | 858 | #define SC_SIZE 0xF000 859 | #define SC_MOVE 0xF010 860 | #define SC_MINIMIZE 0xF020 861 | #define SC_MAXIMIZE 0xF030 862 | #define SC_NEXTWINDOW 0xF040 863 | #define SC_PREVWINDOW 0xF050 864 | #define SC_CLOSE 0xF060 865 | #define SC_VSCROLL 0xF070 866 | #define SC_HSCROLL 0xF080 867 | #define SC_MOUSEMENU 0xF090 868 | #define SC_KEYMENU 0xF100 869 | #define SC_ARRANGE 0xF110 870 | #define SC_RESTORE 0xF120 871 | #define SC_TASKLIST 0xF130 872 | #define SC_SCREENSAVE 0xF140 873 | #define SC_HOTKEY 0xF150 874 | #define SC_DEFAULT 0xF160 875 | #define SC_MONITORPOWER 0xF170 876 | #define SC_CONTEXTHELP 0xF180 877 | #define SC_SEPARATOR 0xF00F 878 | 879 | /* Obsolete names */ 880 | 881 | #define SC_ICON SC_MINIMIZE 882 | #define SC_ZOOM SC_MAXIMIZE 883 | 884 | /* OEM Resource Ordinal Numbers */ 885 | 886 | #define OBM_CLOSE 32754 887 | #define OBM_UPARROW 32753 888 | #define OBM_DNARROW 32752 889 | #define OBM_RGARROW 32751 890 | #define OBM_LFARROW 32750 891 | #define OBM_REDUCE 32749 892 | #define OBM_ZOOM 32748 893 | #define OBM_RESTORE 32747 894 | #define OBM_REDUCED 32746 895 | #define OBM_ZOOMD 32745 896 | #define OBM_RESTORED 32744 897 | #define OBM_UPARROWD 32743 898 | #define OBM_DNARROWD 32742 899 | #define OBM_RGARROWD 32741 900 | #define OBM_LFARROWD 32740 901 | #define OBM_MNARROW 32739 902 | #define OBM_COMBO 32738 903 | #define OBM_UPARROWI 32737 904 | #define OBM_DNARROWI 32736 905 | #define OBM_RGARROWI 32735 906 | #define OBM_LFARROWI 32734 907 | 908 | #define OBM_OLD_CLOSE 32767 909 | #define OBM_SIZE 32766 910 | #define OBM_OLD_UPARROW 32765 911 | #define OBM_OLD_DNARROW 32764 912 | #define OBM_OLD_RGARROW 32763 913 | #define OBM_OLD_LFARROW 32762 914 | #define OBM_BTSIZE 32761 915 | #define OBM_CHECK 32760 916 | #define OBM_CHECKBOXES 32759 917 | #define OBM_BTNCORNERS 32758 918 | #define OBM_OLD_REDUCE 32757 919 | #define OBM_OLD_ZOOM 32756 920 | #define OBM_OLD_RESTORE 32755 921 | 922 | #define OCR_NORMAL 32512 923 | #define OCR_IBEAM 32513 924 | #define OCR_WAIT 32514 925 | #define OCR_CROSS 32515 926 | #define OCR_UP 32516 927 | #define OCR_SIZE 32640 928 | #define OCR_ICON 32641 929 | #define OCR_SIZENWSE 32642 930 | #define OCR_SIZENESW 32643 931 | #define OCR_SIZEWE 32644 932 | #define OCR_SIZENS 32645 933 | #define OCR_SIZEALL 32646 934 | #define OCR_ICOCUR 32647 935 | #define OCR_NO 32648 936 | #define OCR_HAND 32649 937 | #define OCR_APPSTARTING 32650 938 | 939 | #define OIC_SAMPLE 32512 940 | #define OIC_HAND 32513 941 | #define OIC_QUES 32514 942 | #define OIC_BANG 32515 943 | #define OIC_NOTE 32516 944 | #define OIC_WINLOGO 32517 945 | #define OIC_WARNING OIC_BANG 946 | #define OIC_ERROR OIC_HAND 947 | #define OIC_INFORMATION OIC_NOTE 948 | 949 | /* Standard Icon IDs */ 950 | 951 | #define IDI_APPLICATION 32512 952 | #define IDI_HAND 32513 953 | #define IDI_QUESTION 32514 954 | #define IDI_EXCLAMATION 32515 955 | #define IDI_ASTERISK 32516 956 | #define IDI_WINLOGO 32517 957 | 958 | #define IDI_WARNING IDI_EXCLAMATION 959 | #define IDI_ERROR IDI_HAND 960 | #define IDI_INFORMATION IDI_ASTERISK 961 | 962 | /* Dialog Box Command IDs */ 963 | 964 | #define IDOK 1 965 | #define IDCANCEL 2 966 | #define IDABORT 3 967 | #define IDRETRY 4 968 | #define IDIGNORE 5 969 | #define IDYES 6 970 | #define IDNO 7 971 | #define IDCLOSE 8 972 | #define IDHELP 9 973 | 974 | /* Edit Control Styles */ 975 | 976 | #define ES_LEFT 0x0000L 977 | #define ES_CENTER 0x0001L 978 | #define ES_RIGHT 0x0002L 979 | #define ES_MULTILINE 0x0004L 980 | #define ES_UPPERCASE 0x0008L 981 | #define ES_LOWERCASE 0x0010L 982 | #define ES_PASSWORD 0x0020L 983 | #define ES_AUTOVSCROLL 0x0040L 984 | #define ES_AUTOHSCROLL 0x0080L 985 | #define ES_NOHIDESEL 0x0100L 986 | #define ES_OEMCONVERT 0x0400L 987 | #define ES_READONLY 0x0800L 988 | #define ES_WANTRETURN 0x1000L 989 | #define ES_NUMBER 0x2000L 990 | 991 | /* Edit Control Messages */ 992 | 993 | #define EM_GETSEL 0x00B0 994 | #define EM_SETSEL 0x00B1 995 | #define EM_GETRECT 0x00B2 996 | #define EM_SETRECT 0x00B3 997 | #define EM_SETRECTNP 0x00B4 998 | #define EM_SCROLL 0x00B5 999 | #define EM_LINESCROLL 0x00B6 1000 | #define EM_SCROLLCARET 0x00B7 1001 | #define EM_GETMODIFY 0x00B8 1002 | #define EM_SETMODIFY 0x00B9 1003 | #define EM_GETLINECOUNT 0x00BA 1004 | #define EM_LINEINDEX 0x00BB 1005 | #define EM_SETHANDLE 0x00BC 1006 | #define EM_GETHANDLE 0x00BD 1007 | #define EM_GETTHUMB 0x00BE 1008 | #define EM_LINELENGTH 0x00C1 1009 | #define EM_REPLACESEL 0x00C2 1010 | #define EM_GETLINE 0x00C4 1011 | #define EM_LIMITTEXT 0x00C5 1012 | #define EM_CANUNDO 0x00C6 1013 | #define EM_UNDO 0x00C7 1014 | #define EM_FMTLINES 0x00C8 1015 | #define EM_LINEFROMCHAR 0x00C9 1016 | #define EM_SETTABSTOPS 0x00CB 1017 | #define EM_SETPASSWORDCHAR 0x00CC 1018 | #define EM_EMPTYUNDOBUFFER 0x00CD 1019 | #define EM_GETFIRSTVISIBLELINE 0x00CE 1020 | #define EM_SETREADONLY 0x00CF 1021 | #define EM_SETWORDBREAKPROC 0x00D0 1022 | #define EM_GETWORDBREAKPROC 0x00D1 1023 | #define EM_GETPASSWORDCHAR 0x00D2 1024 | #define EM_SETMARGINS 0x00D3 1025 | #define EM_GETMARGINS 0x00D4 1026 | #define EM_SETLIMITTEXT EM_LIMITTEXT 1027 | #define EM_GETLIMITTEXT 0x00D5 1028 | #define EM_POSFROMCHAR 0x00D6 1029 | #define EM_CHARFROMPOS 0x00D7 1030 | 1031 | #define EM_SETIMESTATUS 0x00D8 1032 | #define EM_GETIMESTATUS 0x00D9 1033 | 1034 | /* Button Control Styles */ 1035 | 1036 | #define BS_PUSHBUTTON 0x00000000L 1037 | #define BS_DEFPUSHBUTTON 0x00000001L 1038 | #define BS_CHECKBOX 0x00000002L 1039 | #define BS_AUTOCHECKBOX 0x00000003L 1040 | #define BS_RADIOBUTTON 0x00000004L 1041 | #define BS_3STATE 0x00000005L 1042 | #define BS_AUTO3STATE 0x00000006L 1043 | #define BS_GROUPBOX 0x00000007L 1044 | #define BS_USERBUTTON 0x00000008L 1045 | #define BS_AUTORADIOBUTTON 0x00000009L 1046 | #define BS_OWNERDRAW 0x0000000BL 1047 | #define BS_LEFTTEXT 0x00000020L 1048 | #define BS_TEXT 0x00000000L 1049 | #define BS_ICON 0x00000040L 1050 | #define BS_BITMAP 0x00000080L 1051 | #define BS_LEFT 0x00000100L 1052 | #define BS_RIGHT 0x00000200L 1053 | #define BS_CENTER 0x00000300L 1054 | #define BS_TOP 0x00000400L 1055 | #define BS_BOTTOM 0x00000800L 1056 | #define BS_VCENTER 0x00000C00L 1057 | #define BS_PUSHLIKE 0x00001000L 1058 | #define BS_MULTILINE 0x00002000L 1059 | #define BS_NOTIFY 0x00004000L 1060 | #define BS_FLAT 0x00008000L 1061 | #define BS_RIGHTBUTTON BS_LEFTTEXT 1062 | 1063 | /* User Button Notification Codes */ 1064 | 1065 | #define BN_CLICKED 0 1066 | #define BN_PAINT 1 1067 | #define BN_HILITE 2 1068 | #define BN_UNHILITE 3 1069 | #define BN_DISABLE 4 1070 | #define BN_DOUBLECLICKED 5 1071 | #define BN_PUSHED BN_HILITE 1072 | #define BN_UNPUSHED BN_UNHILITE 1073 | #define BN_DBLCLK BN_DOUBLECLICKED 1074 | #define BN_SETFOCUS 6 1075 | #define BN_KILLFOCUS 7 1076 | 1077 | /* Button Control Messages */ 1078 | 1079 | #define BM_GETCHECK 0x00F0 1080 | #define BM_SETCHECK 0x00F1 1081 | #define BM_GETSTATE 0x00F2 1082 | #define BM_SETSTATE 0x00F3 1083 | #define BM_SETSTYLE 0x00F4 1084 | #define BM_CLICK 0x00F5 1085 | #define BM_GETIMAGE 0x00F6 1086 | #define BM_SETIMAGE 0x00F7 1087 | 1088 | #define BST_UNCHECKED 0x0000 1089 | #define BST_CHECKED 0x0001 1090 | #define BST_INDETERMINATE 0x0002 1091 | #define BST_PUSHED 0x0004 1092 | #define BST_FOCUS 0x0008 1093 | 1094 | /* Static Control Constants */ 1095 | 1096 | #define SS_LEFT 0x00000000L 1097 | #define SS_CENTER 0x00000001L 1098 | #define SS_RIGHT 0x00000002L 1099 | #define SS_ICON 0x00000003L 1100 | #define SS_BLACKRECT 0x00000004L 1101 | #define SS_GRAYRECT 0x00000005L 1102 | #define SS_WHITERECT 0x00000006L 1103 | #define SS_BLACKFRAME 0x00000007L 1104 | #define SS_GRAYFRAME 0x00000008L 1105 | #define SS_WHITEFRAME 0x00000009L 1106 | #define SS_USERITEM 0x0000000AL 1107 | #define SS_SIMPLE 0x0000000BL 1108 | #define SS_LEFTNOWORDWRAP 0x0000000CL 1109 | #define SS_OWNERDRAW 0x0000000DL 1110 | #define SS_BITMAP 0x0000000EL 1111 | #define SS_ENHMETAFILE 0x0000000FL 1112 | #define SS_ETCHEDHORZ 0x00000010L 1113 | #define SS_ETCHEDVERT 0x00000011L 1114 | #define SS_ETCHEDFRAME 0x00000012L 1115 | #define SS_TYPEMASK 0x0000001FL 1116 | #define SS_NOPREFIX 0x00000080L 1117 | #define SS_NOTIFY 0x00000100L 1118 | #define SS_CENTERIMAGE 0x00000200L 1119 | #define SS_RIGHTJUST 0x00000400L 1120 | #define SS_REALSIZEIMAGE 0x00000800L 1121 | #define SS_SUNKEN 0x00001000L 1122 | #define SS_ENDELLIPSIS 0x00004000L 1123 | #define SS_PATHELLIPSIS 0x00008000L 1124 | #define SS_WORDELLIPSIS 0x0000C000L 1125 | #define SS_ELLIPSISMASK 0x0000C000L 1126 | 1127 | /* Dialog Styles */ 1128 | 1129 | #define DS_ABSALIGN 0x01L 1130 | #define DS_SYSMODAL 0x02L 1131 | #define DS_LOCALEDIT 0x20L 1132 | #define DS_SETFONT 0x40L 1133 | #define DS_MODALFRAME 0x80L 1134 | #define DS_NOIDLEMSG 0x100L 1135 | #define DS_SETFOREGROUND 0x200L 1136 | 1137 | #define DS_3DLOOK 0x0004L 1138 | #define DS_FIXEDSYS 0x0008L 1139 | #define DS_NOFAILCREATE 0x0010L 1140 | #define DS_CONTROL 0x0400L 1141 | #define DS_CENTER 0x0800L 1142 | #define DS_CENTERMOUSE 0x1000L 1143 | #define DS_CONTEXTHELP 0x2000L 1144 | 1145 | /* Listbox Styles */ 1146 | 1147 | #define LBS_NOTIFY 0x0001L 1148 | #define LBS_SORT 0x0002L 1149 | #define LBS_NOREDRAW 0x0004L 1150 | #define LBS_MULTIPLESEL 0x0008L 1151 | #define LBS_OWNERDRAWFIXED 0x0010L 1152 | #define LBS_OWNERDRAWVARIABLE 0x0020L 1153 | #define LBS_HASSTRINGS 0x0040L 1154 | #define LBS_USETABSTOPS 0x0080L 1155 | #define LBS_NOINTEGRALHEIGHT 0x0100L 1156 | #define LBS_MULTICOLUMN 0x0200L 1157 | #define LBS_WANTKEYBOARDINPUT 0x0400L 1158 | #define LBS_EXTENDEDSEL 0x0800L 1159 | #define LBS_DISABLENOSCROLL 0x1000L 1160 | #define LBS_NODATA 0x2000L 1161 | #define LBS_NOSEL 0x4000L 1162 | #define LBS_STANDARD (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER) 1163 | 1164 | /* Combo Box styles */ 1165 | 1166 | #define CBS_SIMPLE 0x0001L 1167 | #define CBS_DROPDOWN 0x0002L 1168 | #define CBS_DROPDOWNLIST 0x0003L 1169 | #define CBS_OWNERDRAWFIXED 0x0010L 1170 | #define CBS_OWNERDRAWVARIABLE 0x0020L 1171 | #define CBS_AUTOHSCROLL 0x0040L 1172 | #define CBS_OEMCONVERT 0x0080L 1173 | #define CBS_SORT 0x0100L 1174 | #define CBS_HASSTRINGS 0x0200L 1175 | #define CBS_NOINTEGRALHEIGHT 0x0400L 1176 | #define CBS_DISABLENOSCROLL 0x0800L 1177 | #define CBS_UPPERCASE 0x2000L 1178 | #define CBS_LOWERCASE 0x4000L 1179 | 1180 | /* Scroll Bar Styles */ 1181 | 1182 | #define SBS_HORZ 0x0000L 1183 | #define SBS_VERT 0x0001L 1184 | #define SBS_TOPALIGN 0x0002L 1185 | #define SBS_LEFTALIGN 0x0002L 1186 | #define SBS_BOTTOMALIGN 0x0004L 1187 | #define SBS_RIGHTALIGN 0x0004L 1188 | #define SBS_SIZEBOXTOPLEFTALIGN 0x0002L 1189 | #define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L 1190 | #define SBS_SIZEBOX 0x0008L 1191 | #define SBS_SIZEGRIP 0x0010L 1192 | 1193 | /* Commands to pass to WinHelp() */ 1194 | 1195 | #define HELP_CONTEXT 0x0001L 1196 | #define HELP_QUIT 0x0002L 1197 | #define HELP_INDEX 0x0003L 1198 | #define HELP_CONTENTS 0x0003L 1199 | #define HELP_HELPONHELP 0x0004L 1200 | #define HELP_SETINDEX 0x0005L 1201 | #define HELP_SETCONTENTS 0x0005L 1202 | #define HELP_CONTEXTPOPUP 0x0008L 1203 | #define HELP_FORCEFILE 0x0009L 1204 | #define HELP_KEY 0x0101L 1205 | #define HELP_COMMAND 0x0102L 1206 | #define HELP_PARTIALKEY 0x0105L 1207 | #define HELP_MULTIKEY 0x0201L 1208 | #define HELP_SETWINPOS 0x0203L 1209 | #define HELP_CONTEXTMENU 0x000a 1210 | #define HELP_FINDER 0x000b 1211 | #define HELP_WM_HELP 0x000c 1212 | #define HELP_SETPOPUP_POS 0x000d 1213 | 1214 | #define HELP_TCARD 0x8000 1215 | #define HELP_TCARD_DATA 0x0010 1216 | #define HELP_TCARD_OTHER_CALLER 0x0011 1217 | 1218 | /* These are in winhelp.h in Win95. */ 1219 | 1220 | #define IDH_NO_HELP 28440 1221 | #define IDH_MISSING_CONTEXT 28441 1222 | #define IDH_GENERIC_HELP_BUTTON 28442 1223 | #define IDH_OK 28443 1224 | #define IDH_CANCEL 28444 1225 | #define IDH_HELP 28445 1226 | 1227 | 1228 | --------------------------------------------------------------------------------