From ce49c84f3a26f016f9232d2bffdc830d7fd6169f Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 30 Aug 2014 11:37:47 +0000 Subject: Tox: - switch to offline when connection is lost - file transfer support - code refactoring - project reordering - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10340 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/docs/README.md | 18 -- protocols/Tox/docs/dlltolib/deflibcreator/as.exe | Bin 792360 -> 0 bytes protocols/Tox/docs/dlltolib/deflibcreator/as64.exe | Bin 1510620 -> 0 bytes .../docs/dlltolib/deflibcreator/deflibcreator.exe | Bin 77824 -> 0 bytes .../Tox/docs/dlltolib/deflibcreator/dlltool.exe | Bin 611153 -> 0 bytes .../Tox/docs/dlltolib/deflibcreator/dlltool64.exe | Bin 1023386 -> 0 bytes protocols/Tox/docs/dlltolib/deflibcreator/link.exe | Bin 733440 -> 0 bytes .../docs/dlltolib/deflibcreator/link.exe.manifest | 11 - .../Tox/docs/dlltolib/deflibcreator/mspdb80.dll | Bin 173056 -> 0 bytes .../dlltolib/deflibcreator/mspdb80.dll.2.manifest | 11 - .../Tox/docs/dlltolib/deflibcreator/src/build.cmd | 5 - .../dlltolib/deflibcreator/src/deflib.manifest | 8 - .../dlltolib/deflibcreator/src/deflibcreator.cpp | 310 --------------------- .../Tox/docs/dlltolib/deflibcreator/src/dlc.ico | Bin 34494 -> 0 bytes .../docs/dlltolib/deflibcreator/src/resource.rc | 94 ------- protocols/Tox/docs/dlltolib/start.cmd | 3 - 16 files changed, 460 deletions(-) delete mode 100644 protocols/Tox/docs/README.md delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/as.exe delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/as64.exe delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/deflibcreator.exe delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/dlltool.exe delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/dlltool64.exe delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/link.exe delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/link.exe.manifest delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll.2.manifest delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/src/build.cmd delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/src/deflib.manifest delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/src/deflibcreator.cpp delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/src/dlc.ico delete mode 100644 protocols/Tox/docs/dlltolib/deflibcreator/src/resource.rc delete mode 100644 protocols/Tox/docs/dlltolib/start.cmd (limited to 'protocols/Tox/docs') diff --git a/protocols/Tox/docs/README.md b/protocols/Tox/docs/README.md deleted file mode 100644 index 0879158997..0000000000 --- a/protocols/Tox/docs/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Prerequisites -------------- - -You will need PowerShell for preparing the `.def` file. - -### Tox-Core - -Download Tox DLL from [the CI server](https://jenkins.libtoxcore.so/job/toxcore_win32_dll/). Put that DLL into `dll` directory, copy the `include` files. - -Now you need to prepare the `.def` file for the DLL. You have to prepare the corresponding `.lib` file for the DLL. To do it, start PowerShell and enter a Visual Studio command environment. Then execute the following script: - - PS> 'EXPORTS' | Out-File .\libtox.def -Encoding ascii; dumpbin.exe /exports .\libtox.dll | % { ($_ -split '\s+')[4] } | Out-File .\libtox.def -Append -Encoding ascii - -It prepares the `def` file for the next step - the `lib` tool: - - PS> lib /def:libtox.def /out:libtox.lib /machine:x86 - -You'll get the `libtox.lib` import library in the current directory. Copy it to `lib` project directory and you're ready! diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/as.exe b/protocols/Tox/docs/dlltolib/deflibcreator/as.exe deleted file mode 100644 index e1b3143100..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/as.exe and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/as64.exe b/protocols/Tox/docs/dlltolib/deflibcreator/as64.exe deleted file mode 100644 index 4f5095abf8..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/as64.exe and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/deflibcreator.exe b/protocols/Tox/docs/dlltolib/deflibcreator/deflibcreator.exe deleted file mode 100644 index 5969f5d4c2..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/deflibcreator.exe and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/dlltool.exe b/protocols/Tox/docs/dlltolib/deflibcreator/dlltool.exe deleted file mode 100644 index 7874bdd13e..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/dlltool.exe and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/dlltool64.exe b/protocols/Tox/docs/dlltolib/deflibcreator/dlltool64.exe deleted file mode 100644 index 6a41e5228c..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/dlltool64.exe and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/link.exe b/protocols/Tox/docs/dlltolib/deflibcreator/link.exe deleted file mode 100644 index 5215aecd5d..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/link.exe and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/link.exe.manifest b/protocols/Tox/docs/dlltolib/deflibcreator/link.exe.manifest deleted file mode 100644 index 2981431665..0000000000 --- a/protocols/Tox/docs/dlltolib/deflibcreator/link.exe.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll b/protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll deleted file mode 100644 index cbe888915c..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll.2.manifest b/protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll.2.manifest deleted file mode 100644 index 2981431665..0000000000 --- a/protocols/Tox/docs/dlltolib/deflibcreator/mspdb80.dll.2.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/src/build.cmd b/protocols/Tox/docs/dlltolib/deflibcreator/src/build.cmd deleted file mode 100644 index abcf258d0a..0000000000 --- a/protocols/Tox/docs/dlltolib/deflibcreator/src/build.cmd +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -rc /d "_UNICODE" /d "UNICODE" /fo".\release\resource.res" resource.rc -cl /EHsc /DUNICODE /D_UNICODE /Ox /Oi /Ot /DWIN32 /DNDEBUG /nologo /GL /TP /GS /Gz /MD deflibcreator.cpp /link /LTCG /release /manifest:no /Machine:x86 .\release\resource.res /out:.\release\deflibcreator.exe -del deflibcreator.obj -del .\release\resource.res \ No newline at end of file diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/src/deflib.manifest b/protocols/Tox/docs/dlltolib/deflibcreator/src/deflib.manifest deleted file mode 100644 index 414433b643..0000000000 --- a/protocols/Tox/docs/dlltolib/deflibcreator/src/deflib.manifest +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/src/deflibcreator.cpp b/protocols/Tox/docs/dlltolib/deflibcreator/src/deflibcreator.cpp deleted file mode 100644 index 6480fda7e3..0000000000 --- a/protocols/Tox/docs/dlltolib/deflibcreator/src/deflibcreator.cpp +++ /dev/null @@ -1,310 +0,0 @@ -#define WIN32_LEAN_AND_MEAN -#define _WIN32_WINNT 0x0501 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma comment(lib, "dbghelp.lib") -#pragma comment(lib, "shlwapi.lib") -#pragma comment(lib, "shell32.lib") - -// ordinals to names -typedef std::map > ExportMap; - -void GetExports(PVOID pMapping, ExportMap& exports, WORD& imageType) -{ - ULONG size = 0; - PIMAGE_NT_HEADERS pHead = ImageNtHeader(pMapping); - PIMAGE_EXPORT_DIRECTORY pDir = static_cast(ImageDirectoryEntryToData(pMapping, FALSE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size)); - if(pHead && pDir) - { - imageType = pHead->FileHeader.Machine; - char* base = static_cast(pMapping); - DWORD rvaExportDir = reinterpret_cast(pDir) - base; - PIMAGE_SECTION_HEADER pSec = NULL; - PDWORD namesAddr = static_cast(ImageRvaToVa(pHead, pMapping, pDir->AddressOfNames, &pSec)); - PWORD ordinalAddr = static_cast(ImageRvaToVa(pHead, pMapping, pDir->AddressOfNameOrdinals, &pSec)); - DWORD numFuncs = pDir->NumberOfFunctions; - DWORD numNames = pDir->NumberOfNames; - DWORD baseOrd = pDir->Base; - - std::set ordinals; - DWORD lastOrd = baseOrd + numFuncs; - for(DWORD i = baseOrd; i < lastOrd; ++i) - { - ordinals.insert(i); - } - - for(DWORD i = 0; i < numNames; ++i) - { - WORD thisZeroBasedOrd = ordinalAddr[i]; - DWORD thisBasedOrd = thisZeroBasedOrd + baseOrd; - ordinals.erase(thisBasedOrd); - LPCSTR name = static_cast(ImageRvaToVa(pHead, pMapping, namesAddr[i], &pSec)); - exports[thisBasedOrd].push_back(name); - } - - for(std::set::const_iterator iter = ordinals.begin(), end = ordinals.end(); - iter != end; - ++iter - ) - { - exports.insert(std::make_pair(*iter, ExportMap::mapped_type())); - } - } -} - -PVOID MapFile(HANDLE hFile, DWORD fileMapPerm, DWORD mappedPerms) -{ - PVOID base = NULL; - HANDLE hMap = CreateFileMappingW( - hFile, - NULL, - fileMapPerm, - 0, - 0, - NULL - ); - if(hMap) - { - base = MapViewOfFile(hMap, mappedPerms, 0, 0, 0); - CloseHandle(hMap); - } - return base; -} - -PVOID MapFile(const wchar_t* fileName, DWORD filePerms, DWORD fileMapPerm, DWORD mappedPerms) -{ - PVOID base = NULL; - HANDLE hFile = CreateFileW( - fileName, - filePerms, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL - ); - if(hFile != INVALID_HANDLE_VALUE) - { - base = MapFile(hFile, fileMapPerm, mappedPerms); - CloseHandle(hFile); - } - return base; -} - -PVOID MapFileRO(const wchar_t* fileName, BOOL image) -{ - return MapFile(fileName, GENERIC_READ, PAGE_READONLY | (image ? SEC_IMAGE : 0), FILE_MAP_READ); -} - -std::wstring GetFileName(const wchar_t* pFilePath) -{ - const wchar_t* pAfterSlash = pFilePath, *pSlash = NULL; - while((pSlash = wcspbrk(pAfterSlash, L"\\/")) != NULL) - { - pAfterSlash = pSlash + 1; - } - const wchar_t* pDot = wcschr(pAfterSlash, L'.'); - if(pDot != NULL) - { - return std::wstring(pAfterSlash, pDot); - } - else return std::wstring(pAfterSlash); -} - -std::wstring MakeWString(const char* string) -{ - size_t reqd = mbstowcs(NULL, string, 0); - if(reqd != static_cast(-1)) - { - std::wstring str(reqd, 0); - mbstowcs(&str[0], string, reqd); - return str; - } - return std::wstring(string, string + strlen(string) + 1); -} - -void DoAndWaitForExecution(SHELLEXECUTEINFO& sei) -{ - if(!ShellExecuteEx(&sei)) - { - std::wcerr << L"Couldn't execute \"" << sei.lpFile << L'\n'; - } - else - { - WaitForSingleObject(sei.hProcess, INFINITE); - CloseHandle(sei.hProcess); - } -} - -void CreateLibs(const std::wstring& defFile, const std::wstring& baseName, const std::wstring& outDir, WORD machineType) -{ - std::wstring curDir(1000, 0); - curDir.resize(GetModuleFileName(GetModuleHandle(NULL), &curDir[0], curDir.length())); - curDir.resize(curDir.find_last_of(L"\\/") + 1); - SHELLEXECUTEINFO sei = {sizeof(sei), 0}; - sei.fMask = SEE_MASK_NOCLOSEPROCESS; - sei.hwnd = GetConsoleWindow(); - sei.lpVerb = L"open"; - sei.lpDirectory = outDir.c_str(); - - // 32-bit libs - if(machineType == IMAGE_FILE_MACHINE_I386) - { - std::wcout << L"Creating 32-bit libs...\n"; - // dlltool for mingw (x86) - std::wcout << L"\tCreating lib" << baseName << L".a...\n"; - std::wostringstream pstream; - pstream << L"-d \"" << defFile << L"\" -l lib" << baseName << L".a"; - - std::wstring binary = curDir + L"dlltool.exe"; - std::wstring parameters = pstream.str(); - - sei.lpFile = binary.c_str(); - sei.lpParameters = parameters.c_str(); - - DoAndWaitForExecution(sei); - - pstream.str(L""); - - // link for msvc (x86) - std::wcout << L"\tCreating " << baseName << L".lib...\n"; - pstream << L"/lib /nologo /machine:x86 /def:\"" << defFile << "\" /out:\"" << outDir << baseName << L".lib\""; - - binary = curDir + L"link.exe"; - parameters = pstream.str(); - sei.lpFile = binary.c_str(); - sei.lpParameters = parameters.c_str(); - DoAndWaitForExecution(sei); - } - else - { - std::wcout << L"Creating 64-bit libs...\n"; - // dlltool for mingw (x64) (my fail if running on 32-bit comp) - std::wcout << L"\tlib" << baseName << L"-x64.a...\n"; - - std::wstring binary = curDir + L"dlltool64.exe"; - std::wstring as64Pos = L"\""; - as64Pos += (curDir + L"as64.exe\""); - std::wostringstream pstream; - pstream << L"-d \"" << defFile << L"\" -S " << as64Pos << L" -l lib" << baseName << L"-x64.a"; - - std::wstring parameters = pstream.str(); - sei.lpFile = binary.c_str(); - sei.lpParameters = parameters.c_str(); - DoAndWaitForExecution(sei); - - pstream.str(L""); - - // link for msvc (x64) - std::wcout << L'\t' << baseName << L"-x64.lib...\n"; - binary = curDir + L"link.exe"; - pstream << L"/lib /nologo /machine:x64 /def:\"" << defFile << "\" /out:\"" << outDir << baseName << L"-x64.lib\""; - parameters = pstream.str(); - sei.lpFile = binary.c_str(); - sei.lpParameters = parameters.c_str(); - DoAndWaitForExecution(sei); - } -} - -BOOL CreateDef(LPCWSTR dllFile, const std::wstring& defFile, WORD& machineType) -{ - std::wcout << L"Creating " << defFile << L"...\n"; - // this is FALSE on purpose. If it's true, some dll's (mainly bcrypt.dll from Vista) - // fail to map as an image because of some funkyness with the certificate or - // something (STATUS_INVALID_IMAGE_HASH fyi). So this is just easier - PVOID pMapping = MapFileRO(dllFile, FALSE); - if(pMapping) - { - ExportMap exports; - GetExports(pMapping, exports, machineType); - if(!exports.empty()) - { - std::wofstream defFile(defFile.c_str()); - std::wostringstream expDetails; - defFile << L"LIBRARY \"" << GetFileName(dllFile) << L"\"\n\nEXPORTS\n"; - for(ExportMap::const_iterator iter = exports.begin(), end = exports.end(); - iter != end; - ++iter - ) - { - expDetails.str(L""); - expDetails.clear(); - expDetails << L'\t'; - const ExportMap::mapped_type& names = iter->second; - if(!names.empty()) - { - const std::wstring& initialName = MakeWString(*(names.begin())); - expDetails << initialName << L"\t@" << iter->first << L'\n'; - for(ExportMap::mapped_type::const_iterator namesIter = names.begin() + 1, namesEnd = names.end(); - namesIter != namesEnd; - ++namesIter - ) - { - expDetails << '\t' << MakeWString(*namesIter) << L'=' << initialName << L'\n'; - } - } - // unnamed export - else - { - expDetails << L"Ordinal" << iter->first << L" NONAME\t@" << iter->first << L'\n'; - } - defFile << expDetails.str(); - } - } - else - { - std::wcerr << dllFile << L" has no exports, nothing to do\n"; - return FALSE; - } - UnmapViewOfFile(pMapping); - } - return TRUE; -} - -int __cdecl wmain(int argc, wchar_t** argv) -{ - std::wcout << L"DefLibCreator v1.0 - Airesoft.co.uk\n\n"; - if(argc < 2) - { - puts("Usage: DefLibCreator dll [outDir]"); - return 1; - } - else - { - std::wstring baseFileName = PathFindFileName(argv[1]); - baseFileName.erase(baseFileName.find_last_of('.')); - int outDirArg = (argc >= 3) ? 2 : 1; - LPWSTR pFilePart = NULL; - std::wstring outDir(GetFullPathName(argv[outDirArg], 0, NULL, NULL), 0); - outDir.resize(GetFullPathName(argv[outDirArg], outDir.length(), &outDir[0], &pFilePart)); - // if the explicit output dir wasn't specified, we need to chop the dll filename off the end of outDir - if(outDirArg == 1) - { - outDir.resize(pFilePart - outDir.c_str()); - } - else - { - CreateDirectory(outDir.c_str(), NULL); - } - outDir.push_back(L'\\'); // ensure it ends with a slash - std::wstring defFile(outDir); - defFile += (baseFileName + L".def"); - WORD machineType = 0; - if(CreateDef(argv[1], defFile, machineType)) - { - CreateLibs(defFile, baseFileName, outDir, machineType); - } - } - return 0; -} diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/src/dlc.ico b/protocols/Tox/docs/dlltolib/deflibcreator/src/dlc.ico deleted file mode 100644 index aa524c729c..0000000000 Binary files a/protocols/Tox/docs/dlltolib/deflibcreator/src/dlc.ico and /dev/null differ diff --git a/protocols/Tox/docs/dlltolib/deflibcreator/src/resource.rc b/protocols/Tox/docs/dlltolib/deflibcreator/src/resource.rc deleted file mode 100644 index 503ec99a76..0000000000 --- a/protocols/Tox/docs/dlltolib/deflibcreator/src/resource.rc +++ /dev/null @@ -1,94 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winresrc.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.K.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN -END - -2 TEXTINCLUDE -BEGIN - "#include ""winresrc.h""\r\0" -END - -3 TEXTINCLUDE -BEGIN -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -1 ICON "dlc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904b0" - BEGIN - VALUE "CompanyName", "Airesoft" - VALUE "FileDescription", "DefLibCreator" - VALUE "FileVersion", "1, 0, 0, 0" - VALUE "InternalName", "DefLibCreator.exe" - VALUE "LegalCopyright", "Copyright (C) Airesoft 2012" - VALUE "OriginalFilename", "DefLibCreator.exe" - VALUE "ProductName", "DefLibCreator" - VALUE "ProductVersion", "1, 0, 0, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1200 - END -END - -#endif // English (U.K.) resources -///////////////////////////////////////////////////////////////////////////// - -/// Manifest -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST deflib.manifest \ No newline at end of file diff --git a/protocols/Tox/docs/dlltolib/start.cmd b/protocols/Tox/docs/dlltolib/start.cmd deleted file mode 100644 index 913dca85c7..0000000000 --- a/protocols/Tox/docs/dlltolib/start.cmd +++ /dev/null @@ -1,3 +0,0 @@ -deflibcreator\deflibcreator ..\..\dll\x86\libtox.dll ..\..\lib\x86\ - -deflibcreator\deflibcreator ..\..\dll\x64\libtox.dll ..\..\lib\x64\ -- cgit v1.2.3