summaryrefslogtreecommitdiff
path: root/plugins/Utils
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-07-26 08:46:45 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-07-26 08:46:45 +0000
commit12718514fb673dbb72f7d93ea3bb34c9574bd69a (patch)
tree91569255bd22163c21eb9f22ceb388db16f53e19 /plugins/Utils
parent3856c86d711275b80e09371cad10b8b828a5879a (diff)
replace sprintf to mir_snprintf (part 7)
removed not used files git-svn-id: http://svn.miranda-ng.org/main/trunk@5490 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils')
-rw-r--r--plugins/Utils/ContactAsyncQueue.cpp234
-rw-r--r--plugins/Utils/ContactAsyncQueue.h95
-rw-r--r--plugins/Utils/MemoryModule.c540
-rw-r--r--plugins/Utils/MemoryModule.h48
-rw-r--r--plugins/Utils/mir_dbutils.h70
-rw-r--r--plugins/Utils/mir_log.cpp220
-rw-r--r--plugins/Utils/mir_log.h63
-rw-r--r--plugins/Utils/mir_options_notify.cpp199
-rw-r--r--plugins/Utils/mir_options_notify.h69
-rw-r--r--plugins/Utils/mir_profiler.cpp178
-rw-r--r--plugins/Utils/mir_profiler.h77
-rw-r--r--plugins/Utils/mir_scope.h35
-rw-r--r--plugins/Utils/templates.cpp473
-rw-r--r--plugins/Utils/templates.h102
-rw-r--r--plugins/Utils/tstring.h14
15 files changed, 0 insertions, 2417 deletions
diff --git a/plugins/Utils/ContactAsyncQueue.cpp b/plugins/Utils/ContactAsyncQueue.cpp
deleted file mode 100644
index 2d5d1f104d..0000000000
--- a/plugins/Utils/ContactAsyncQueue.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-Copyright (C) 2006-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "ContactAsyncQueue.h"
-#include <process.h>
-
-
-// Itens with higher time at end
-static int QueueSortItems(const QueueItem *oldItem, const QueueItem *newItem)
-{
- if (oldItem->check_time == newItem->check_time)
- return -1;
-
- return oldItem->check_time - newItem->check_time;
-}
-
-// Itens with higher time at end
-static void ContactAsyncQueueThread(void *obj)
-{
- ((ContactAsyncQueue *)obj)->Thread();
-}
-
-ContactAsyncQueue::ContactAsyncQueue(pfContactAsyncQueueCallback fContactAsyncQueueCallback, int initialSize)
- : queue(30, QueueSortItems)
-{
- hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- finished = 0;
- callback = fContactAsyncQueueCallback;
-
- InitializeCriticalSection(&cs);
-
- _beginthread(ContactAsyncQueueThread, 0, this);
- //mir_forkthread(ContactAsyncQueueThread, this);
-}
-
-ContactAsyncQueue::~ContactAsyncQueue()
-{
- Finish();
-
- int count = 0;
- while(finished != 2 && ++count < 50)
- Sleep(30);
-
- for (int i = 0; i < queue.getCount(); i++)
- if (queue[i] != NULL)
- mir_free(queue[i]);
-
- DeleteCriticalSection(&cs);
-}
-
-void ContactAsyncQueue::Finish()
-{
- if (finished == 0)
- finished = 1;
- SetEvent(hEvent);
-}
-
-void ContactAsyncQueue::Lock()
-{
- EnterCriticalSection(&cs);
-}
-
-void ContactAsyncQueue::Release()
-{
- LeaveCriticalSection(&cs);
-}
-
-void ContactAsyncQueue::RemoveAll(HANDLE hContact)
-{
- Lock();
-
- for (int i = queue.getCount() - 1; i >= 0; --i)
- {
- QueueItem *item = queue[i];
-
- if (item->hContact == hContact)
- {
- queue.remove(i);
- mir_free(item);
- }
- }
-
- Release();
-}
-
-void ContactAsyncQueue::RemoveAllConsiderParam(HANDLE hContact, void *param)
-{
- Lock();
-
- for (int i = queue.getCount() - 1; i >= 0; --i)
- {
- QueueItem *item = queue[i];
-
- if (item->hContact == hContact && item->param == param)
- {
- queue.remove(i);
- mir_free(item);
- }
- }
-
- Release();
-}
-
-void ContactAsyncQueue::Add(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::AddIfDontHave(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- int i;
- for (i = queue.getCount() - 1; i >= 0; --i)
- if (queue[i]->hContact == hContact)
- break;
-
- if (i < 0)
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::AddAndRemovePrevious(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- RemoveAll(hContact);
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::AddAndRemovePreviousConsiderParam(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- RemoveAllConsiderParam(hContact, param);
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::InternalAdd(int waitTime, HANDLE hContact, void *param)
-{
- QueueItem *item = (QueueItem *) mir_alloc(sizeof(QueueItem));
- item->hContact = hContact;
- item->check_time = GetTickCount() + waitTime;
- item->param = param;
-
- queue.insert(item);
-
- SetEvent(hEvent);
-}
-
-void ContactAsyncQueue::Thread()
-{
- while (!finished)
- {
- ResetEvent(hEvent);
-
- if (finished)
- break;
-
- Lock();
-
- if (queue.getCount() <= 0)
- {
- // No items, so supend thread
- Release();
-
- wait(/*INFINITE*/ 2 * 60 * 1000);
- }
- else
- {
- // Take a look at first item
- QueueItem *qi = queue[0];
-
- int dt = qi->check_time - GetTickCount();
- if (dt > 0)
- {
- // Not time to request yet, wait...
- Release();
-
- wait(dt);
- }
- else
- {
- // Will request this item
- queue.remove(0);
-
- Release();
-
- callback(qi->hContact, qi->param);
-
- mir_free(qi);
- }
- }
- }
-
- finished = 2;
-}
-
-void ContactAsyncQueue::wait(int time)
-{
- if (!finished)
- WaitForSingleObject(hEvent, time);
-}
-
-
-
-
-
-
diff --git a/plugins/Utils/ContactAsyncQueue.h b/plugins/Utils/ContactAsyncQueue.h
deleted file mode 100644
index b38509869d..0000000000
--- a/plugins/Utils/ContactAsyncQueue.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-Copyright (C) 2006-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __CONTACTASYNCQUEUE_H__
-# define __CONTACTASYNCQUEUE_H__
-
-#ifndef MIRANDA_VER
-#define MIRANDA_VER 0x0A00
-#endif
-
-#include <windows.h>
-#include <newpluginapi.h>
-#include <m_system_cpp.h>
-
-
-typedef void (*pfContactAsyncQueueCallback) (HANDLE hContact, void *param);
-
-
-struct QueueItem
-{
- DWORD check_time;
- HANDLE hContact;
- void *param;
-};
-
-
-class ContactAsyncQueue
-{
-public:
-
- ContactAsyncQueue(pfContactAsyncQueueCallback fContactAsyncQueueCallback, int initialSize = 10);
- ~ContactAsyncQueue();
-
- void Finish();
-
- inline int Size() const { return queue.getCount(); }
- inline int Remove(int idx) { mir_free(queue[idx]); return queue.remove(idx); }
- inline QueueItem* Get(int idx) const { return queue[idx]; }
-
-
- void RemoveAll(HANDLE hContact);
- void RemoveAllConsiderParam(HANDLE hContact, void *param);
- void Add(int waitTime, HANDLE hContact, void *param = NULL);
- void AddIfDontHave(int waitTime, HANDLE hContact, void *param = NULL);
- void AddAndRemovePrevious(int waitTime, HANDLE hContact, void *param = NULL);
- void AddAndRemovePreviousConsiderParam(int waitTime, HANDLE hContact, void *param = NULL);
-
- void Lock();
- void Release();
-
-
- void Thread();
-
-private:
-
- LIST<QueueItem> queue;
-
- CRITICAL_SECTION cs;
- pfContactAsyncQueueCallback callback;
- HANDLE hEvent;
- int finished;
-
-
- void InternalAdd(int waitTime, HANDLE hContact, void *param);
- void wait(int time);
-};
-
-
-
-
-
-
-
-
-
-
-
-#endif // __CONTACTASYNCQUEUE_H__
diff --git a/plugins/Utils/MemoryModule.c b/plugins/Utils/MemoryModule.c
deleted file mode 100644
index 1e7ac0ac01..0000000000
--- a/plugins/Utils/MemoryModule.c
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Memory DLL loading code
- * Version 0.0.2 with additions from Thomas Heller
- *
- * Copyright (c) 2004-2005 by Joachim Bauch / mail@joachim-bauch.de
- * http://www.joachim-bauch.de
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is MemoryModule.c
- *
- * The Initial Developer of the Original Code is Joachim Bauch.
- *
- * Portions created by Joachim Bauch are Copyright (C) 2004-2005
- * Joachim Bauch. All Rights Reserved.
- *
- * Portions Copyright (C) 2005 Thomas Heller.
- *
- */
-
-// disable warnings about pointer <-> DWORD conversions
-#pragma warning( disable : 4311 4312 )
-
-#include <Windows.h>
-#include <winnt.h>
-#ifdef DEBUG_OUTPUT
-#include <stdio.h>
-#endif
-
-#ifndef IMAGE_SIZEOF_BASE_RELOCATION
-// Vista SDKs no longer define IMAGE_SIZEOF_BASE_RELOCATION!?
-# define IMAGE_SIZEOF_BASE_RELOCATION (sizeof(IMAGE_BASE_RELOCATION))
-#endif
-#include "MemoryModule.h"
-
-
-struct NAME_TABLE {
- char *name;
- DWORD ordinal;
-};
-
-typedef struct tagMEMORYMODULE {
- PIMAGE_NT_HEADERS headers;
- unsigned char *codeBase;
- HMODULE *modules;
- int numModules;
- int initialized;
-
- struct NAME_TABLE *name_table;
-} MEMORYMODULE, *PMEMORYMODULE;
-
-typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
-
-#define GET_HEADER_DICTIONARY(module, idx) &(module)->headers->OptionalHeader.DataDirectory[idx]
-
-#ifdef DEBUG_OUTPUT
-static void
-OutputLastError(const char *msg)
-{
- LPVOID tmp;
- char *tmpmsg;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&tmp, 0, NULL);
- tmpmsg = (char *)LocalAlloc(LPTR, strlen(msg) + strlen(tmp) + 3);
- sprintf(tmpmsg, "%s: %s", msg, tmp);
- OutputDebugString(tmpmsg);
- LocalFree(tmpmsg);
- LocalFree(tmp);
-}
-#endif
-
-static void
-CopySections(const unsigned char *data, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module)
-{
- int i, size;
- unsigned char *codeBase = module->codeBase;
- unsigned char *dest;
- PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
- for (i=0; i<module->headers->FileHeader.NumberOfSections; i++, section++)
- {
- if (section->SizeOfRawData == 0)
- {
- // section doesn't contain data in the dll itself, but may define
- // uninitialized data
- size = old_headers->OptionalHeader.SectionAlignment;
- if (size > 0)
- {
- dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress,
- size,
- MEM_COMMIT,
- PAGE_READWRITE);
-
- section->Misc.PhysicalAddress = (DWORD)dest;
- memset(dest, 0, size);
- }
-
- // section is empty
- continue;
- }
-
- // commit memory block and copy data from dll
- dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress,
- section->SizeOfRawData,
- MEM_COMMIT,
- PAGE_READWRITE);
- memcpy(dest, data + section->PointerToRawData, section->SizeOfRawData);
- section->Misc.PhysicalAddress = (DWORD)dest;
- }
-}
-
-// Protection flags for memory pages (Executable, Readable, Writeable)
-static int ProtectionFlags[2][2][2] = {
- {
- // not executable
- {PAGE_NOACCESS, PAGE_WRITECOPY},
- {PAGE_READONLY, PAGE_READWRITE},
- }, {
- // executable
- {PAGE_EXECUTE, PAGE_EXECUTE_WRITECOPY},
- {PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE},
- },
-};
-
-static void
-FinalizeSections(PMEMORYMODULE module)
-{
- int i;
- PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
-
- // loop through all sections and change access flags
- for (i=0; i<module->headers->FileHeader.NumberOfSections; i++, section++)
- {
- DWORD protect, oldProtect, size;
- int executable = (section->Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
- int readable = (section->Characteristics & IMAGE_SCN_MEM_READ) != 0;
- int writeable = (section->Characteristics & IMAGE_SCN_MEM_WRITE) != 0;
-
- if (section->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
- {
- // section is not needed any more and can safely be freed
- VirtualFree((LPVOID)section->Misc.PhysicalAddress, section->SizeOfRawData, MEM_DECOMMIT);
- continue;
- }
-
- // determine protection flags based on characteristics
- protect = ProtectionFlags[executable][readable][writeable];
- if (section->Characteristics & IMAGE_SCN_MEM_NOT_CACHED)
- protect |= PAGE_NOCACHE;
-
- // determine size of region
- size = section->SizeOfRawData;
- if (size == 0)
- {
- if (section->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA)
- size = module->headers->OptionalHeader.SizeOfInitializedData;
- else if (section->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
- size = module->headers->OptionalHeader.SizeOfUninitializedData;
- }
-
- if (size > 0)
- {
- // change memory access flags
- if (VirtualProtect((LPVOID)section->Misc.PhysicalAddress, size, protect, &oldProtect) == 0)
-#ifdef DEBUG_OUTPUT
- OutputLastError("Error protecting memory page")
-#endif
- ;
- }
- }
-}
-
-static void
-PerformBaseRelocation(PMEMORYMODULE module, DWORD delta)
-{
- DWORD i;
- unsigned char *codeBase = module->codeBase;
-
- PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_BASERELOC);
- if (directory->Size > 0)
- {
- PIMAGE_BASE_RELOCATION relocation = (PIMAGE_BASE_RELOCATION)(codeBase + directory->VirtualAddress);
- for (; relocation->VirtualAddress > 0; )
- {
- unsigned char *dest = (unsigned char *)(codeBase + relocation->VirtualAddress);
- unsigned short *relInfo = (unsigned short *)((unsigned char *)relocation + IMAGE_SIZEOF_BASE_RELOCATION);
- for (i=0; i<((relocation->SizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION) / 2); i++, relInfo++)
- {
- DWORD *patchAddrHL;
- int type, offset;
-
- // the upper 4 bits define the type of relocation
- type = *relInfo >> 12;
- // the lower 12 bits define the offset
- offset = *relInfo & 0xfff;
-
- switch (type)
- {
- case IMAGE_REL_BASED_ABSOLUTE:
- // skip relocation
- break;
-
- case IMAGE_REL_BASED_HIGHLOW:
- // change complete 32 bit address
- patchAddrHL = (DWORD *)(dest + offset);
- *patchAddrHL += delta;
- break;
-
- default:
- //printf("Unknown relocation: %d\n", type);
- break;
- }
- }
-
- // advance to next relocation block
- relocation = (PIMAGE_BASE_RELOCATION)(((DWORD)relocation) + relocation->SizeOfBlock);
- }
- }
-}
-
-static int
-BuildImportTable(PMEMORYMODULE module)
-{
- int result=1;
- unsigned char *codeBase = module->codeBase;
-
- PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_IMPORT);
- if (directory->Size > 0)
- {
- PIMAGE_IMPORT_DESCRIPTOR importDesc = (PIMAGE_IMPORT_DESCRIPTOR)(codeBase + directory->VirtualAddress);
- for (; !IsBadReadPtr(importDesc, sizeof(IMAGE_IMPORT_DESCRIPTOR)) && importDesc->Name; importDesc++)
- {
- DWORD *thunkRef, *funcRef;
- HMODULE handle = LoadLibraryA((LPCSTR)(codeBase + importDesc->Name));
- if (handle == INVALID_HANDLE_VALUE || handle == NULL)
- {
- //LastError should already be set
-#if DEBUG_OUTPUT
- OutputLastError("Can't load library");
-#endif
- result = 0;
- break;
- }
-
- module->modules = (HMODULE *)realloc(module->modules, (module->numModules+1)*(sizeof(HMODULE)));
- if (module->modules == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- result = 0;
- break;
- }
-
- module->modules[module->numModules++] = handle;
- if (importDesc->OriginalFirstThunk)
- {
- thunkRef = (DWORD *)(codeBase + importDesc->OriginalFirstThunk);
- funcRef = (DWORD *)(codeBase + importDesc->FirstThunk);
- } else {
- // no hint table
- thunkRef = (DWORD *)(codeBase + importDesc->FirstThunk);
- funcRef = (DWORD *)(codeBase + importDesc->FirstThunk);
- }
- for (; *thunkRef; thunkRef++, funcRef++)
- {
- if IMAGE_SNAP_BY_ORDINAL(*thunkRef)
- *funcRef = (DWORD)GetProcAddress(handle, (LPCSTR)IMAGE_ORDINAL(*thunkRef));
- else {
- PIMAGE_IMPORT_BY_NAME thunkData = (PIMAGE_IMPORT_BY_NAME)(codeBase + *thunkRef);
- *funcRef = (DWORD)GetProcAddress(handle, (LPCSTR)&thunkData->Name);
- }
- if (*funcRef == 0)
- {
- SetLastError(ERROR_PROC_NOT_FOUND);
- result = 0;
- break;
- }
- }
-
- if (!result)
- break;
- }
- }
-
- return result;
-}
-
-HMEMORYMODULE MemoryLoadLibrary(const void *data)
-{
- PMEMORYMODULE result;
- PIMAGE_DOS_HEADER dos_header;
- PIMAGE_NT_HEADERS old_header;
- unsigned char *code, *headers;
- DWORD locationDelta;
- DllEntryProc DllEntry;
- BOOL successfull;
-
- dos_header = (PIMAGE_DOS_HEADER)data;
- if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
- {
- SetLastError(ERROR_BAD_FORMAT);
-#if DEBUG_OUTPUT
- OutputDebugString("Not a valid executable file.\n");
-#endif
- return NULL;
- }
-
- old_header = (PIMAGE_NT_HEADERS)&((const unsigned char *)(data))[dos_header->e_lfanew];
- if (old_header->Signature != IMAGE_NT_SIGNATURE)
- {
- SetLastError(ERROR_BAD_FORMAT);
-#if DEBUG_OUTPUT
- OutputDebugString("No PE header found.\n");
-#endif
- return NULL;
- }
-
- // reserve memory for image of library
- code = (unsigned char *)VirtualAlloc((LPVOID)(old_header->OptionalHeader.ImageBase),
- old_header->OptionalHeader.SizeOfImage,
- MEM_RESERVE,
- PAGE_READWRITE);
-
- if (code == NULL)
- // try to allocate memory at arbitrary position
- code = (unsigned char *)VirtualAlloc(NULL,
- old_header->OptionalHeader.SizeOfImage,
- MEM_RESERVE,
- PAGE_READWRITE);
-
- if (code == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-#if DEBUG_OUTPUT
- OutputLastError("Can't reserve memory");
-#endif
- return NULL;
- }
-
- result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE));
- result->codeBase = code;
- result->numModules = 0;
- result->modules = NULL;
- result->initialized = 0;
- result->name_table = NULL;
-
- // XXX: is it correct to commit the complete memory region at once?
- // calling DllEntry raises an exception if we don't...
- VirtualAlloc(code,
- old_header->OptionalHeader.SizeOfImage,
- MEM_COMMIT,
- PAGE_READWRITE);
-
- // commit memory for headers
- headers = (unsigned char *)VirtualAlloc(code,
- old_header->OptionalHeader.SizeOfHeaders,
- MEM_COMMIT,
- PAGE_READWRITE);
-
- // copy PE header to code
- memcpy(headers, dos_header, dos_header->e_lfanew + old_header->OptionalHeader.SizeOfHeaders);
- result->headers = (PIMAGE_NT_HEADERS)&((const unsigned char *)(headers))[dos_header->e_lfanew];
-
- // update position
- result->headers->OptionalHeader.ImageBase = (DWORD)code;
-
- // copy sections from DLL file block to new memory location
- CopySections(data, old_header, result);
-
- // adjust base address of imported data
- locationDelta = (DWORD)(code - old_header->OptionalHeader.ImageBase);
- if (locationDelta != 0)
- PerformBaseRelocation(result, locationDelta);
-
- // load required dlls and adjust function table of imports
- if (!BuildImportTable(result))
- goto error;
-
- // mark memory pages depending on section headers and release
- // sections that are marked as "discardable"
- FinalizeSections(result);
-
- // get entry point of loaded library
- if (result->headers->OptionalHeader.AddressOfEntryPoint != 0)
- {
- DllEntry = (DllEntryProc)(code + result->headers->OptionalHeader.AddressOfEntryPoint);
- if (DllEntry == 0)
- {
- SetLastError(ERROR_BAD_FORMAT); /* XXX ? */
-#if DEBUG_OUTPUT
- OutputDebugString("Library has no entry point.\n");
-#endif
- goto error;
- }
-
- // notify library about attaching to process
- successfull = (*DllEntry)((HINSTANCE)code, DLL_PROCESS_ATTACH, 0);
- if (!successfull)
- {
-#if DEBUG_OUTPUT
- OutputDebugString("Can't attach library.\n");
-#endif
- goto error;
- }
- result->initialized = 1;
- }
-
- return (HMEMORYMODULE)result;
-
-error:
- // cleanup
- MemoryFreeLibrary(result);
- return NULL;
-}
-
-int _compare(const struct NAME_TABLE *p1, const struct NAME_TABLE *p2)
-{
- return stricmp(p1->name, p2->name);
-}
-
-int _find(const char **name, const struct NAME_TABLE *p)
-{
- return stricmp(*name, p->name);
-}
-
-struct NAME_TABLE *GetNameTable(PMEMORYMODULE module)
-{
- unsigned char *codeBase;
- PIMAGE_EXPORT_DIRECTORY exports;
- PIMAGE_DATA_DIRECTORY directory;
- DWORD i, *nameRef;
- WORD *ordinal;
- struct NAME_TABLE *p, *ptab;
-
- if (module->name_table)
- return module->name_table;
-
- codeBase = module->codeBase;
- directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_EXPORT);
- exports = (PIMAGE_EXPORT_DIRECTORY)(codeBase + directory->VirtualAddress);
-
- nameRef = (DWORD *)(codeBase + exports->AddressOfNames);
- ordinal = (WORD *)(codeBase + exports->AddressOfNameOrdinals);
-
- p = ((PMEMORYMODULE)module)->name_table = (struct NAME_TABLE *)malloc(sizeof(struct NAME_TABLE)
- * exports->NumberOfNames);
- if (p == NULL)
- return NULL;
- ptab = p;
- for (i=0; i<exports->NumberOfNames; ++i) {
- p->name = (char *)(codeBase + *nameRef++);
- p->ordinal = *ordinal++;
- ++p;
- }
- qsort(ptab, exports->NumberOfNames, sizeof(struct NAME_TABLE), _compare);
- return ptab;
-}
-
-FARPROC MemoryGetProcAddress(HMEMORYMODULE module, const char *name)
-{
- unsigned char *codeBase = ((PMEMORYMODULE)module)->codeBase;
- int idx=-1;
- PIMAGE_EXPORT_DIRECTORY exports;
- PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE)module, IMAGE_DIRECTORY_ENTRY_EXPORT);
-
- if (directory->Size == 0)
- // no export table found
- return NULL;
-
- exports = (PIMAGE_EXPORT_DIRECTORY)(codeBase + directory->VirtualAddress);
- if (exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0)
- // DLL doesn't export anything
- return NULL;
-
- if (HIWORD(name)) {
- struct NAME_TABLE *ptab;
- struct NAME_TABLE *found;
- ptab = GetNameTable((PMEMORYMODULE)module);
- if (ptab == NULL)
- // some failure
- return NULL;
- found = bsearch(&name, ptab, exports->NumberOfNames, sizeof(struct NAME_TABLE), _find);
- if (found == NULL)
- // exported symbol not found
- return NULL;
-
- idx = found->ordinal;
- }
- else
- idx = LOWORD(name) - exports->Base;
-
- if ((DWORD)idx > exports->NumberOfFunctions)
- // name <-> ordinal number don't match
- return NULL;
-
- // AddressOfFunctions contains the RVAs to the "real" functions
- return (FARPROC)(codeBase + *(DWORD *)(codeBase + exports->AddressOfFunctions + (idx*4)));
-}
-
-void MemoryFreeLibrary(HMEMORYMODULE mod)
-{
- int i;
- PMEMORYMODULE module = (PMEMORYMODULE)mod;
-
- if (module != NULL)
- {
- if (module->initialized != 0)
- {
- // notify library about detaching from process
- DllEntryProc DllEntry = (DllEntryProc)(module->codeBase + module->headers->OptionalHeader.AddressOfEntryPoint);
- (*DllEntry)((HINSTANCE)module->codeBase, DLL_PROCESS_DETACH, 0);
- module->initialized = 0;
- }
-
- if (module->modules != NULL)
- {
- // free previously opened libraries
- for (i=0; i<module->numModules; i++)
- if (module->modules[i] != INVALID_HANDLE_VALUE)
- FreeLibrary(module->modules[i]);
-
- free(module->modules);
- }
-
- if (module->codeBase != NULL)
- // release memory of library
- VirtualFree(module->codeBase, 0, MEM_RELEASE);
-
- if (module->name_table != NULL)
- free(module->name_table);
-
- HeapFree(GetProcessHeap(), 0, module);
- }
-}
diff --git a/plugins/Utils/MemoryModule.h b/plugins/Utils/MemoryModule.h
deleted file mode 100644
index f314e5d1fb..0000000000
--- a/plugins/Utils/MemoryModule.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Memory DLL loading code
- * Version 0.0.2
- *
- * Copyright (c) 2004-2005 by Joachim Bauch / mail@joachim-bauch.de
- * http://www.joachim-bauch.de
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is MemoryModule.h
- *
- * The Initial Developer of the Original Code is Joachim Bauch.
- *
- * Portions created by Joachim Bauch are Copyright (C) 2004-2005
- * Joachim Bauch. All Rights Reserved.
- *
- */
-
-#ifndef __MEMORY_MODULE_HEADER
-#define __MEMORY_MODULE_HEADER
-
-#include <Windows.h>
-
-typedef void *HMEMORYMODULE;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HMEMORYMODULE MemoryLoadLibrary(const void *);
-
-FARPROC MemoryGetProcAddress(HMEMORYMODULE, const char *);
-
-void MemoryFreeLibrary(HMEMORYMODULE);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __MEMORY_MODULE_HEADER
diff --git a/plugins/Utils/mir_dbutils.h b/plugins/Utils/mir_dbutils.h
deleted file mode 100644
index cb7400a5ff..0000000000
--- a/plugins/Utils/mir_dbutils.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-#ifndef __DBUTILS_H__
-# define __DBUTILS_H__
-
-
-class DBTString
-{
- DBVARIANT dbv;
- bool exists;
-
-public:
- DBTString(HANDLE hContact, char *module, char *setting)
- {
- ZeroMemory(&dbv, sizeof(dbv));
- exists = (DBGetContactSettingTString(hContact, module, setting, &dbv) == 0);
- }
-
- ~DBTString()
- {
- if (exists)
- DBFreeVariant(&dbv);
- }
-
- const TCHAR * get() const
- {
- if (!exists)
- return NULL;
- else
- return dbv.ptszVal;
- }
-
- const bool operator==(const TCHAR *other)
- {
- return get() == other;
- }
-
- const bool operator!=(const TCHAR *other)
- {
- return get() != other;
- }
-
- operator const TCHAR *() const
- {
- return get();
- }
-};
-
-
-
-
-
-
-#endif // __DBUTILS_H__
diff --git a/plugins/Utils/mir_log.cpp b/plugins/Utils/mir_log.cpp
deleted file mode 100644
index 5a5a18060f..0000000000
--- a/plugins/Utils/mir_log.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-Copyright (C) 2005-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#include "mir_log.h"
-
-#include <stdio.h>
-
-#include <newpluginapi.h>
-#include <m_netlib.h>
-#include <m_protocols.h>
-#include <m_clist.h>
-
-#define ENABLE_LOG
-
-
-int MLog::deep = 0;
-
-MLog::MLog(const char *aModule, const char *aFunction)
- : module(aModule)
-{
- memset(&total, 0, sizeof(total));
-
- function = "";
- for(int i = 0; i < deep; i++)
- function += " ";
- function += aFunction;
-
- deep ++;
-
- mlog(module.c_str(), function.c_str(), "BEGIN");
-
- StartTimer();
-}
-
-MLog::~MLog()
-{
- StopTimer();
-
- mlog(module.c_str(), function.c_str(), "END in %2.1lf ms", GetTotalTimeMS());
- deep --;
-}
-
-int MLog::log(const char *fmt, ...)
-{
- StopTimer();
-
- double elapsed = GetElapsedTimeMS();
-
- va_list va;
- va_start(va, fmt);
-
- char text[1024];
- mir_snprintf(text, sizeof(text) - 10, "%s [in %2.1lf ms | total %2.1lf ms]",
- fmt, GetElapsedTimeMS(), GetTotalTimeMS());
-
- int ret = mlog(module.c_str(), function.c_str(), text, va);
-
- va_end(va);
-
- StartTimer();
-
- return ret;
-}
-
-void MLog::StartTimer()
-{
- QueryPerformanceCounter(&start);
-}
-
-void MLog::StopTimer()
-{
- QueryPerformanceCounter(&end);
-
- total.QuadPart += end.QuadPart - start.QuadPart;
-}
-
-double MLog::GetElapsedTimeMS()
-{
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
-
- return (end.QuadPart - start.QuadPart) * 1000. / frequency.QuadPart;
-}
-
-double MLog::GetTotalTimeMS()
-{
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
-
- return total.QuadPart * 1000. / frequency.QuadPart;
-}
-
-
-int mlog(const char *module, const char *function, const char *fmt, va_list va)
-{
-#ifdef ENABLE_LOG
-
- char text[1024];
- size_t len;
-
- mir_snprintf(text, sizeof(text) - 10, "[%08u - %08u] [%s] [%s] ",
- GetCurrentThreadId(), GetTickCount(), module, function);
- len = strlen(text);
-
- mir_vsnprintf(&text[len], sizeof(text) - len, fmt, va);
-
-#ifdef LOG_TO_NETLIB
-
- return CallService(MS_NETLIB_LOG, NULL, (LPARAM) text);
-
-#else
- char file[256];
- _snprintf(file, sizeof(file), "c:\\miranda_%s.log.txt", module);
-
- FILE *fp = fopen(file,"at");
-
- if (fp != NULL)
- {
- fprintf(fp, "%s\n", text);
- fclose(fp);
- return 0;
- }
- else
- {
- return -1;
- }
-
-#endif
-
-#else
-
- return 0;
-
-#endif
-}
-
-
-int mlog(const char *module, const char *function, const char *fmt, ...)
-{
- va_list va;
- va_start(va, fmt);
-
- int ret = mlog(module, function, fmt, va);
-
- va_end(va);
-
- return ret;
-}
-
-int mlogC(const char *module, const char *function, HANDLE hContact, const char *fmt, ...)
-{
-#ifdef ENABLE_LOG
-
- va_list va;
- char text[1024];
- size_t len;
-
- char *name = NULL;
- char *proto = NULL;
- if (hContact != NULL)
- {
- name = (char*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0);
- proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- }
-
- mir_snprintf(text, sizeof(text) - 10, "[%08u - %08u] [%s] [%s] [%08d - %s - %s] ",
- GetCurrentThreadId(), GetTickCount(), module, function,
- hContact, proto == NULL ? "" : proto, name == NULL ? "" : name);
- len = strlen(text);
-
- va_start(va, fmt);
- mir_vsnprintf(&text[len], sizeof(text) - len, fmt, va);
- va_end(va);
-
-#ifdef LOG_TO_NETLIB
-
- return CallService(MS_NETLIB_LOG, NULL, (LPARAM) text);
-
-#else
- char file[256];
- _snprintf(file, sizeof(file), "c:\\miranda_%s.log.txt", module);
-
- FILE *fp = fopen(file,"at");
-
- if (fp != NULL)
- {
- fprintf(fp, "%s\n", text);
- fclose(fp);
- return 0;
- }
- else
- {
- return -1;
- }
-
-#endif
-
-#else
-
- return 0;
-
-#endif
-}
diff --git a/plugins/Utils/mir_log.h b/plugins/Utils/mir_log.h
deleted file mode 100644
index 5785e191ff..0000000000
--- a/plugins/Utils/mir_log.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright (C) 2005-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __LOG_H__
-# define __LOG_H__
-
-#include <windows.h>
-#include <string>
-
-
-int mlog(const char *module, const char *function, const char *fmt, ...);
-int mlog(const char *module, const char *function, const char *fmt, va_list va);
-int mlogC(const char *module, const char *function, HANDLE hContact, const char *fmt, ...);
-
-
-#ifdef __cplusplus
-
-class MLog
-{
-private:
- std::string module;
- std::string function;
- LARGE_INTEGER start;
- LARGE_INTEGER end;
- LARGE_INTEGER total;
-
- static int deep;
-
- void StartTimer();
- void StopTimer();
- double GetElapsedTimeMS();
- double GetTotalTimeMS();
-
-public:
- MLog(const char *aModule, const char *aFunction);
- ~MLog();
-
- int log(const char *fmt, ...);
-};
-
-
-#endif __cplusplus
-
-
-
-#endif // __LOG_H__
diff --git a/plugins/Utils/mir_options_notify.cpp b/plugins/Utils/mir_options_notify.cpp
deleted file mode 100644
index b2ee76a512..0000000000
--- a/plugins/Utils/mir_options_notify.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#include "mir_options_notify.h"
-
-#include <stdio.h>
-#include <commctrl.h>
-#include <tchar.h>
-
-extern "C"
-{
-#include <newpluginapi.h>
-#include <m_database.h>
-#include <m_utils.h>
-#include <m_langpack.h>
-#include <m_notify.h>
-#include "templates.h"
-}
-
-
-#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) )
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Dialog to save options
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-BOOL CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg)
- {
- case WM_USER+100:
- {
- HANDLE hNotify = (HANDLE)lParam;
- SetWindowLongPtr(hwndDlg, GWL_USERDATA, lParam);
-
- TranslateDialogDefault(hwndDlg);
-
- for (int i = 0 ; i < controlsSize ; i++)
- {
- OptPageControl *ctrl = &controls[i];
-
- switch(ctrl->type)
- {
- case CONTROL_CHECKBOX:
- {
- CheckDlgButton(hwndDlg, ctrl->nID, MNotifyGetByte(hNotify, ctrl->setting, (BYTE)ctrl->dwDefValue) == 1 ? BST_CHECKED : BST_UNCHECKED);
- break;
- }
- case CONTROL_SPIN:
- {
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, ctrl->nID),0);
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETRANGE, 0, MAKELONG(ctrl->max, ctrl->min));
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETPOS,0, MAKELONG(MNotifyGetWord(hNotify, ctrl->setting, (WORD)ctrl->dwDefValue), 0));
-
- break;
- }
- case CONTROL_COLOR:
- {
- SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_SETCOLOUR, 0, (COLORREF) MNotifyGetDWord(hNotify, ctrl->setting, (DWORD)ctrl->dwDefValue));
-
- break;
- }
- case CONTROL_RADIO:
- {
- CheckDlgButton(hwndDlg, ctrl->nID, MNotifyGetWord(hNotify, ctrl->setting, (WORD)ctrl->dwDefValue) == ctrl->value ? BST_CHECKED : BST_UNCHECKED);
- break;
- }
- case CONTROL_TEXT:
- {
- SetDlgItemText(hwndDlg, ctrl->nID, MNotifyGetTString(hNotify, ctrl->setting, ctrl->szDefVale));
-
- if (ctrl->max > 0)
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max, 1024), 0);
- else
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 1024, 0);
-
- break;
- }
- case CONTROL_TEMPLATE:
- {
- SetDlgItemText(hwndDlg, ctrl->nID, MNotifyGetTTemplate(hNotify, ctrl->setting, ctrl->szDefVale));
-
- if (ctrl->max > 0)
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max, 1024), 0);
- else
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 1024, 0);
-
- break;
- }
- }
- }
-
- return TRUE;
- break;
- }
- case WM_COMMAND:
- {
- // Don't make apply enabled during buddy set crap
- if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
- {
- for (int i = 0 ; i < controlsSize ; i++)
- {
- if (controls[i].type == CONTROL_SPIN && LOWORD(wParam) == controls[i].nID)
- {
- return 0;
- }
- }
- }
-
- SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HANDLE hNotify = (HANDLE)GetWindowLongPtr(hwndDlg, GWL_USERDATA);
- TCHAR tmp[1024];
-
- for (int i = 0 ; i < controlsSize ; i++)
- {
- OptPageControl *ctrl = &controls[i];
-
- switch(ctrl->type)
- {
- case CONTROL_CHECKBOX:
- {
- MNotifySetByte(hNotify, ctrl->setting, (BYTE)IsDlgButtonChecked(hwndDlg, ctrl->nID));
- break;
- }
- case CONTROL_SPIN:
- {
- MNotifySetWord(hNotify, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_GETPOS, 0, 0));
- break;
- }
- case CONTROL_COLOR:
- {
- MNotifySetDWord(hNotify, ctrl->setting, (DWORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_GETCOLOUR, 0, 0));
- break;
- }
- case CONTROL_RADIO:
- {
- if (IsDlgButtonChecked(hwndDlg, ctrl->nID))
- MNotifySetWord(hNotify, ctrl->setting, (BYTE)ctrl->value);
- break;
- }
- case CONTROL_TEXT:
- {
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp));
- MNotifySetTString(hNotify, ctrl->setting, tmp);
- break;
- }
- case CONTROL_TEMPLATE:
- {
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp));
- MNotifySetTTemplate(hNotify, ctrl->setting, tmp);
- break;
- }
- }
- }
-
- return TRUE;
- }
- }
- break;
- }
- }
- break;
- }
- }
-
- return 0;
-}
diff --git a/plugins/Utils/mir_options_notify.h b/plugins/Utils/mir_options_notify.h
deleted file mode 100644
index 1f5494863a..0000000000
--- a/plugins/Utils/mir_options_notify.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __MIR_OPTIONS_NOTIFY_H__
-# define __MIR_OPTIONS_NOTIFY_H__
-
-#include <windows.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Dialog to save options
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONTROL_CHECKBOX 0 // Stored as BYTE
-#define CONTROL_SPIN 1 // Stored as WORD
-#define CONTROL_COLOR 2 // Stored as DWORD
-#define CONTROL_RADIO 3 // Stored as WORD
-#define CONTROL_TEXT 4 // Stored as char *
-#define CONTROL_TEMPLATE 5 // Stored as Template
-
-struct OptPageControl {
- int type;
- int nID;
- char *setting;
- union {
- DWORD dwDefValue;
- const TCHAR *szDefVale;
- };
- union {
- int nIDSpin;
- int value;
- };
- WORD min;
- WORD max;
-};
-
-BOOL CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __MIR_OPTIONS_NOTIFY_H__
diff --git a/plugins/Utils/mir_profiler.cpp b/plugins/Utils/mir_profiler.cpp
deleted file mode 100644
index b788fd2dd2..0000000000
--- a/plugins/Utils/mir_profiler.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-// Disable "...truncated to '255' characters in the debug information" warnings
-#pragma warning(disable: 4786)
-
-
-#include "mir_profiler.h"
-#include "mir_log.h"
-
-#include <stdio.h>
-
-
-MProfiler::Block MProfiler::root;
-MProfiler::Block * MProfiler::current = &MProfiler::root;
-
-
-MProfiler::Block::Block()
-{
- parent = NULL;
- memset(&total, 0, sizeof(total));
- started = false;
-}
-
-
-MProfiler::Block::~Block()
-{
- Reset();
-}
-
-
-void MProfiler::Block::Reset()
-{
- for(std::map<std::string, MProfiler::Block *>::iterator it = children.begin();
- it != children.end(); ++it)
- delete it->second;
- children.clear();
-
- memset(&total, 0, sizeof(total));
- started = false;
-}
-
-
-void MProfiler::Block::Start()
-{
- if (started)
- return;
-
- QueryPerformanceCounter(&start);
- last_step = start;
- started = true;
-}
-
-
-void MProfiler::Block::Step(const char *name)
-{
- if (!started)
- return;
-
- LARGE_INTEGER end;
- QueryPerformanceCounter(&end);
-
- GetChild(name)->total.QuadPart += end.QuadPart - last_step.QuadPart;
-
- last_step = end;
-}
-
-
-void MProfiler::Block::Stop()
-{
- if (!started)
- return;
-
- LARGE_INTEGER end;
- QueryPerformanceCounter(&end);
-
- total.QuadPart += end.QuadPart - start.QuadPart;
-
- started = false;
-}
-
-
-double MProfiler::Block::GetTimeMS() const
-{
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
-
- return total.QuadPart * 1000. / frequency.QuadPart;
-}
-
-
-MProfiler::Block * MProfiler::Block::GetChild(const char *name)
-{
- MProfiler::Block *ret = children[name];
- if (ret == NULL)
- {
- ret = new MProfiler::Block();
- ret->name = name;
- ret->parent = this;
- children[name] = ret;
- }
- return ret;
-}
-
-
-void MProfiler::Reset()
-{
- root.Reset();
-}
-
-void MProfiler::Start(const char *name)
-{
- current = current->GetChild(name);
- current->Start();
-}
-
-void MProfiler::Step(const char *name)
-{
- current->Step(name);
-}
-
-void MProfiler::End()
-{
- current->Stop();
-
- if (current->parent != NULL)
- {
- current = current->parent;
- QueryPerformanceCounter(&current->last_step);
- }
-}
-
-void MProfiler::Dump(const char *module)
-{
- Dump(module, "", &root, -1, -1);
-}
-
-
-void MProfiler::Dump(const char *module, std::string prefix, Block *block, double parent, double total)
-{
- for(std::map<std::string, MProfiler::Block *>::iterator it = block->children.begin();
- it != block->children.end(); ++it)
- {
- Block *child = it->second;
- double elapsed = child->GetTimeMS();
-
- if (total > 0)
- {
- mlog(module, "Profiler", "%s%-20s\t%5.1lf\t[%3.0lf%%]\t[%3.0lf%%]", prefix.c_str(), it->first.c_str(),
- elapsed, elapsed / parent * 100, elapsed / total * 100);
- }
- else
- {
- mlog(module, "Profiler", "%s%-20s\t%5.1lf", prefix.c_str(), it->first.c_str(),
- elapsed);
- }
-
- Dump(module, prefix + " ", child, elapsed, total > 0 ? total : elapsed);
- }
-}
-
diff --git a/plugins/Utils/mir_profiler.h b/plugins/Utils/mir_profiler.h
deleted file mode 100644
index 92d776f2ee..0000000000
--- a/plugins/Utils/mir_profiler.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __PROFILER_H__
-# define __PROFILER_H__
-
-#include <windows.h>
-#include <string>
-#include <map>
-
-
-
-class MProfiler
-{
-public:
-
- static void Reset();
- static void Start(const char *name);
- static void Step(const char *name);
- static void End();
- static void Dump(const char *module);
-
-
-
- static struct Block
- {
- std::string name;
- Block *parent;
- std::map<std::string, Block *> children;
- bool started;
- LARGE_INTEGER start;
- LARGE_INTEGER last_step;
- LARGE_INTEGER total;
-
- Block();
- ~Block();
-
- void Reset();
- void Start();
- void Step(const char *name);
- void Stop();
- double GetTimeMS() const;
-
- Block * GetChild(const char *name);
- };
-
-
-private:
-
- static Block root;
- static Block *current;
-
- static void Dump(const char *module, std::string prefix, Block *block, double parent, double total);
-
-};
-
-
-
-
-#endif // __PROFILER_H__
diff --git a/plugins/Utils/mir_scope.h b/plugins/Utils/mir_scope.h
deleted file mode 100644
index 2f54044d83..0000000000
--- a/plugins/Utils/mir_scope.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __PTR_H__
-# define __PTR_H__
-
-
-template<class T>
-class scope
-{
-public:
- scope(T t) : p(t) {}
- ~scope() { mir_free(); }
-
- void free()
- {
- if (p != NULL)
- mir_free(p);
- p = NULL;
- }
-
-// T operator->() const { return p; }
- operator T() const { return p; }
-
- T detach()
- {
- T ret = p;
- p = NULL;
- return ret;
- }
-
-private:
- T p;
-};
-
-
-
-#endif // __PTR_H__
diff --git a/plugins/Utils/templates.cpp b/plugins/Utils/templates.cpp
deleted file mode 100644
index 0fbb4715f8..0000000000
--- a/plugins/Utils/templates.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-#include "templates.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <tchar.h>
-
-extern "C"
-{
-#include <newpluginapi.h>
-#include <time.h>
-#include <win2k.h>
-#include <m_system.h>
-#include <m_options.h>
-#include <m_langpack.h>
-#include <m_database.h>
-#include <m_utils.h>
-#include <m_protocols.h>
-
-#include <m_notify.h>
-
-#include "../utils/mir_memory.h"
-}
-
-
-const char *defaultVariables[] = { "%title%", "%text%" };
-const WCHAR *defaultVariablesW[] = { L"%title%", L"%text%" };
-
-const char *defaultVariableDescriptions[] = { "Notification Title", "Notification Text" };
-const WCHAR *defaultVariableDescriptionsW[] = { L"Notification Title", L"Notification Text" };
-
-
-#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) )
-
-
-#define DATA_BLOCK 128
-
-
-// ASCII VERSIONS ///////////////////////////////////////////////////////////////////////
-
-struct StringHelper
-{
- char *text;
- size_t allocated;
- size_t used;
-};
-
-
-int CopyData(StringHelper *str, const char *text, size_t len)
-{
- if (len == 0)
- return 0;
-
- if (text == NULL)
- return 0;
-
- size_t totalSize = str->used + len + 1;
-
- if (totalSize > str->allocated)
- {
- totalSize += DATA_BLOCK - (totalSize % DATA_BLOCK);
-
- if (str->text != NULL)
- {
- char *tmp = (char *) mir_realloc(str->text, sizeof(char) * totalSize);
-
- if (tmp == NULL)
- {
- mir_free(str->text);
- return -1;
- }
-
- str->text = tmp;
- }
- else
- {
- str->text = (char *) mir_alloc(sizeof(char) * totalSize);
-
- if (str->text == NULL)
- {
- return -2;
- }
- }
-
- str->allocated = totalSize;
- }
-
- memmove(&str->text[str->used], text, sizeof(char) * len);
- str->used += len;
- str->text[str->used] = '\0';
-
- return 0;
-}
-
-
-char * ParseText(const char *text,
- const char **variables, size_t variablesSize,
- const char **data, size_t dataSize)
-{
- size_t length = strlen(text);
- size_t nextPos = 0;
- StringHelper ret = {0};
-
- // length - 1 because a % in last char will be a % and point
- for (size_t i = 0 ; i < length - 1 ; i++)
- {
- if (text[i] == '%')
- {
- bool found = false;
-
- if (CopyData(&ret, &text[nextPos], i - nextPos))
- return NULL;
-
- if (text[i + 1] == '%')
- {
- if (CopyData(&ret, "%", 1))
- return NULL;
-
- i++;
-
- found = true;
- }
- else
- {
- size_t size = min(variablesSize, dataSize);
-
- // See if can find it
- for(size_t j = 0 ; j < size ; j++)
- {
- size_t vlen = strlen(variables[j]);
-
- if (strnicmp(&text[i], variables[j], vlen) == 0)
- {
- if (CopyData(&ret, data[j], strlen(data[j])))
- return NULL;
-
- i += vlen - 1;
-
- found = true;
-
- break;
- }
- }
- }
-
-
- if (found)
- nextPos = i + 1;
- else
- nextPos = i;
- }
- }
-
- if (nextPos < length)
- if (CopyData(&ret, &text[nextPos], length - nextPos))
- return NULL;
-
- return ret.text;
-}
-
-
-// UNICODE VERSIONS /////////////////////////////////////////////////////////////////////
-
-struct StringHelperW
-{
- WCHAR *text;
- size_t allocated;
- size_t used;
-};
-
-
-int CopyDataW(StringHelperW *str, const WCHAR *text, size_t len)
-{
- if (len == 0)
- return 0;
-
- if (text == NULL)
- return 0;
-
- size_t totalSize = str->used + len + 1;
-
- if (totalSize > str->allocated)
- {
- totalSize += DATA_BLOCK - (totalSize % DATA_BLOCK);
-
- if (str->text != NULL)
- {
- WCHAR *tmp = (WCHAR *) mir_realloc(str->text, sizeof(WCHAR) * totalSize);
-
- if (tmp == NULL)
- {
- mir_free(str->text);
- return -1;
- }
-
- str->text = tmp;
- }
- else
- {
- str->text = (WCHAR *) mir_alloc(sizeof(WCHAR) * totalSize);
-
- if (str->text == NULL)
- {
- return -2;
- }
- }
-
- str->allocated = totalSize;
- }
-
- memmove(&str->text[str->used], text, sizeof(WCHAR) * len);
- str->used += len;
- str->text[str->used] = '\0';
-
- return 0;
-}
-
-
-WCHAR * ParseTextW(const WCHAR *text,
- const WCHAR **variables, size_t variablesSize,
- const WCHAR **data, size_t dataSize)
-{
- size_t length = lstrlenW(text);
- size_t nextPos = 0;
- StringHelperW ret = {0};
-
- // length - 1 because a % in last char will be a % and point
- for (size_t i = 0 ; i < length - 1 ; i++)
- {
- if (text[i] == L'%')
- {
- bool found = false;
-
- if (CopyDataW(&ret, &text[nextPos], i - nextPos))
- return NULL;
-
- if (text[i + 1] == L'%')
- {
- if (CopyDataW(&ret, L"%", 1))
- return NULL;
-
- i++;
-
- found = true;
- }
- else
- {
- size_t size = min(variablesSize, dataSize);
-
- // See if can find it
- for(size_t j = 0 ; j < size ; j++)
- {
- size_t vlen = lstrlenW(variables[j]);
-
- if (_wcsnicmp(&text[i], variables[j], vlen) == 0)
- {
- if (CopyDataW(&ret, data[j], lstrlenW(data[j])))
- return NULL;
-
- i += vlen - 1;
-
- found = true;
-
- break;
- }
- }
- }
-
- if (found)
- nextPos = i + 1;
- else
- nextPos = i;
- }
- }
-
- if (nextPos < length)
- if (CopyDataW(&ret, &text[nextPos], length - nextPos))
- return NULL;
-
- return ret.text;
-}
-
-
-// INTERFACE ////////////////////////////////////////////////////////////////////////////
-
-// In future maybe pre-parse here
-void MNotifySetTemplate(HANDLE notifyORtype, const char *name, const char *value)
-{
- MNotifySetString(notifyORtype, name, value);
-}
-void MNotifySetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *value)
-{
- MNotifySetWString(notifyORtype, name, value);
-}
-
-// Well, why not?
-const char *MNotifyGetTemplate(HANDLE notifyORtype, const char *name, const char *defValue)
-{
- return MNotifyGetString(notifyORtype, name, defValue);
-}
-const WCHAR *MNotifyGetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue)
-{
- return MNotifyGetWString(notifyORtype, name, defValue);
-}
-
-// You must free the return with mir_sys_free
-char *MNotifyGetParsedTemplate(HANDLE notifyORtype, const char *name, const char *defValue)
-{
- const char *temp = MNotifyGetString(notifyORtype, name, defValue);
-
- if (MNotifyHasVariables(notifyORtype))
- {
- const char ** vars = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRS, NULL);
- size_t varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- const char ** data = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_DATA_STRS, NULL);
- size_t dataSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_DATA_SIZE, 0);
-
- return ParseText(temp, vars, varsSize, data, dataSize);
- }
- else
- {
- // Default values
- const char * data[MAX_REGS(defaultVariables)];
- data[0] = MNotifyGetString(notifyORtype, NFOPT_TITLE, NULL);
- data[1] = MNotifyGetString(notifyORtype, NFOPT_TEXT, NULL);
-
- return ParseText(temp, defaultVariables, MAX_REGS(defaultVariables), data, MAX_REGS(defaultVariables));
- }
-}
-WCHAR *MNotifyGetWParsedTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue)
-{
- const WCHAR *temp = MNotifyGetWString(notifyORtype, name, defValue);
-
- if (MNotifyHasWVariables(notifyORtype))
- {
- const WCHAR ** vars = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRSW, NULL);
- size_t varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- const WCHAR ** data = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_DATA_STRSW, NULL);
- size_t dataSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_DATA_SIZE, 0);
-
- return ParseTextW(temp, vars, varsSize, data, dataSize);
- }
- else
- {
- // Default values
- const WCHAR * data[MAX_REGS(defaultVariablesW)];
- data[0] = MNotifyGetWString(notifyORtype, NFOPT_TITLEW, NULL);
- data[1] = MNotifyGetWString(notifyORtype, NFOPT_TEXTW, NULL);
-
- return ParseTextW(temp, defaultVariablesW, MAX_REGS(defaultVariablesW), data, MAX_REGS(defaultVariablesW));
- }
-}
-
-
-BOOL MNotifyHasVariables(HANDLE notifyORtype)
-{
- return MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRS, NULL) != NULL &&
- MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0) != 0;
-}
-
-BOOL MNotifyHasWVariables(HANDLE notifyORtype)
-{
- return MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRSW, NULL) != NULL &&
- MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0) != 0;
-}
-
-
-
-
-void MNotifyShowVariables(HANDLE notifyORtype)
-{
- StringHelper ret = {0};
-
- const char ** vars;
- size_t varsSize;
- const char ** descs;
- size_t descsSize;
-
- if (MNotifyHasVariables(notifyORtype))
- {
- vars = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRS, NULL);
- varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- descs = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_STRS, NULL);
- descsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_SIZE, 0);
- }
- else
- {
- // Default values
- vars = defaultVariables;
- varsSize = MAX_REGS(defaultVariables);
-
- descs = defaultVariableDescriptions;
- descsSize = MAX_REGS(defaultVariableDescriptions);
- }
-
- for(size_t i = 0 ; i < varsSize ; i++)
- {
- if (vars[i] != NULL)
- {
- if (CopyData(&ret, vars[i], strlen(vars[i])))
- return;
-
- if (i < descsSize && descs[i] != NULL && descs[i] != L'\0')
- {
- if (CopyData(&ret, " -> ", 4))
- return;
- if (CopyData(&ret, descs[i], strlen(descs[i])))
- return;
- }
-
- if (CopyData(&ret, "\r\n", 2))
- return;
- }
- }
-
- MessageBoxA(NULL, ret.text, "Variables", MB_OK);
-
- mir_free(ret.text);
-}
-
-void MNotifyShowWVariables(HANDLE notifyORtype)
-{
- StringHelperW ret = {0};
-
- const WCHAR ** vars;
- size_t varsSize;
- const WCHAR ** descs;
- size_t descsSize;
-
- if (MNotifyHasWVariables(notifyORtype))
- {
- vars = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRSW, NULL);
- varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- descs = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_STRSW, NULL);
- descsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_SIZE, 0);
- }
- else
- {
- // Default values
- vars = defaultVariablesW;
- varsSize = MAX_REGS(defaultVariablesW);
-
- descs = defaultVariableDescriptionsW;
- descsSize = MAX_REGS(defaultVariableDescriptionsW);
- }
-
- for(size_t i = 0 ; i < varsSize ; i++)
- {
- if (vars[i] != NULL)
- {
- if (CopyDataW(&ret, vars[i], lstrlenW(vars[i])))
- return;
-
- if (i < descsSize && descs[i] != NULL && descs[i] != L'\0')
- {
- if (CopyDataW(&ret, L" -> ", 3))
- return;
- if (CopyDataW(&ret, descs[i], lstrlenW(descs[i])))
- return;
- }
-
- if (CopyDataW(&ret, L"\r\n", 2))
- return;
- }
- }
-
- MessageBoxW(NULL, ret.text, L"Variables", MB_OK);
-
- mir_free(ret.text);
-}
diff --git a/plugins/Utils/templates.h b/plugins/Utils/templates.h
deleted file mode 100644
index e55fb7a50e..0000000000
--- a/plugins/Utils/templates.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef __TEMPLATES_H__
-# define __TEMPLATES_H__
-
-
-#include <windows.h>
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-// Default templates to be set by using notifiers
-
-#define NFOPT_DEFTEMPL_TEXT "General/DefaultTemplate/Text"
-#define NFOPT_DEFTEMPL_TEXTW "General/DefaultTemplate/TextW"
-#define NFOPT_DEFTEMPL_TITLE "General/DefaultTemplate/Title"
-#define NFOPT_DEFTEMPL_TITLEW "General/DefaultTemplate/TitleW"
-
-
-
-
-// All of theese have to be stored as DWORDs
-
-#define NFOPT_VARIABLES_STRS "Variables/Strings" // char ** (each has to start and end with %)
-#define NFOPT_VARIABLES_DESCRIPTIONS_STRS "VariablesDescriptions/Strings" // char **
-#define NFOPT_DATA_STRS "Data/Strings" // char **
-
-#define NFOPT_VARIABLES_STRSW "Variables/StringsW" // WCHAR ** (each has to start and end with %)
-#define NFOPT_VARIABLES_DESCRIPTIONS_STRSW "VariablesDescriptions/StringsW"// WCHAR **
-#define NFOPT_DATA_STRSW "Data/StringsW" // WCHAR **
-
-#define NFOPT_VARIABLES_SIZE "Variables/Size" // size_t
-#define NFOPT_VARIABLES_DESCRIPTIONS_SIZE "VariablesDescriptions/Size" // size_t
-#define NFOPT_DATA_SIZE "Data/Size" // size_t
-
-
-// Default variables if none is provided by the plugin calling the notification
-// char *defaultVariables[] = { "%title%", "%text%" };
-
-
-void MNotifySetTemplate(HANDLE notifyORtype, const char *name, const char *value);
-void MNotifySetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *value);
-
-const char *MNotifyGetTemplate(HANDLE notifyORtype, const char *name, const char *defValue);
-const WCHAR *MNotifyGetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue);
-
-// You must free the return with mir_sys_free
-char *MNotifyGetParsedTemplate(HANDLE notifyORtype, const char *name, const char *defValue);
-WCHAR *MNotifyGetWParsedTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue);
-
-
-BOOL MNotifyHasVariables(HANDLE notifyORtype);
-BOOL MNotifyHasWVariables(HANDLE notifyORtype);
-
-void MNotifyShowVariables(HANDLE notifyORtype);
-void MNotifyShowWVariables(HANDLE notifyORtype);
-
-
-#ifdef _UNICODE
-
-# define MNotifyGetTString MNotifyGetWString
-# define MNotifyGetTTemplate MNotifyGetWTemplate
-# define MNotifySetTString MNotifySetWString
-# define MNotifySetTTemplate MNotifyGetWTemplate
-# define MNotifyGetTParsedTemplate MNotifyGetWParsedTemplate
-# define MNotifyHasTVariables MNotifyHasWVariables
-# define MNotifyShowTVariables MNotifyShowWVariables
-
-# define NFOPT_DEFTEMPL_TEXTT NFOPT_DEFTEMPL_TEXTW
-# define NFOPT_DEFTEMPL_TITLET NFOPT_DEFTEMPL_TITLEW
-
-# define NFOPT_VARIABLES_STRST NFOPT_VARIABLES_STRSW
-# define NFOPT_VARIABLES_DESCRIPTIONS_STRST NFOPT_VARIABLES_DESCRIPTIONS_STRSW
-# define NFOPT_DATA_STRST NFOPT_DATA_STRSW
-
-
-#else
-
-# define MNotifyGetTString MNotifyGetString
-# define MNotifyGetTTemplate MNotifyGetTemplate
-# define MNotifySetTString MNotifySetString
-# define MNotifySetTTemplate MNotifySetTemplate
-# define MNotifyGetTParsedTemplate MNotifyGetParsedTemplate
-# define MNotifyHasTVariables MNotifyHasVariables
-# define MNotifyShowTVariables MNotifyShowVariables
-
-# define NFOPT_DEFTEMPL_TEXTT NFOPT_DEFTEMPL_TEXT
-# define NFOPT_DEFTEMPL_TITLET NFOPT_DEFTEMPL_TITLE
-
-# define NFOPT_VARIABLES_STRST NFOPT_VARIABLES_STRS
-# define NFOPT_VARIABLES_DESCRIPTIONS_STRST NFOPT_VARIABLES_DESCRIPTIONS_STRS
-# define NFOPT_DATA_STRST NFOPT_DATA_STRS
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __TEMPLATES_H__
diff --git a/plugins/Utils/tstring.h b/plugins/Utils/tstring.h
deleted file mode 100644
index fb340bcd03..0000000000
--- a/plugins/Utils/tstring.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __TSTRING_H__
-# define __TSTRING_H__
-
-#include <windows.h>
-#include <tchar.h>
-#include <string>
-
-
-namespace std {
- typedef basic_string<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > tstring;
-}
-
-
-#endif // __TSTRING_H__