Preparations for 1.2 update.
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "Display.h"
|
||||
|
||||
std::list<Display>* Display_List = NULL;
|
||||
|
||||
void Display_OnProcessAttach() {
|
||||
Display_List = new std::list<Display>();
|
||||
}
|
||||
|
||||
void Display_OnProcessDetach() {
|
||||
Display_List->clear();
|
||||
delete Display_List;
|
||||
}
|
||||
|
||||
DLL_EXPORT void Display_Enumerate() {
|
||||
if (Display_List == NULL)
|
||||
return;
|
||||
|
||||
Display_List->clear();
|
||||
|
||||
EnumDisplayMonitors(NULL, NULL, Display_EnumerateProcedure, 0);
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:Display_Enumerate=_Display_Enumerate@0")
|
||||
|
||||
BOOL CALLBACK Display_EnumerateProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
||||
Display *thisDisplay = new Display;
|
||||
|
||||
thisDisplay->left = lprcMonitor->left;
|
||||
thisDisplay->top = lprcMonitor->top;
|
||||
thisDisplay->right = lprcMonitor->right;
|
||||
thisDisplay->bottom = lprcMonitor->bottom;
|
||||
|
||||
Display_List->push_back(*thisDisplay);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DLL_EXPORT int Display_Count() {
|
||||
return Display_List->size();
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:Display_Count=_Display_Count@0")
|
||||
|
||||
DLL_EXPORT void Display_Get(uint32_t displayId, LPRECT display) {
|
||||
if (Display_List->size() > displayId) {
|
||||
auto iterator = Display_List->begin();
|
||||
|
||||
std::advance(iterator, displayId);
|
||||
|
||||
if (display != NULL) {
|
||||
display->left = iterator->left;
|
||||
display->top = iterator->top;
|
||||
display->right = iterator->right;
|
||||
display->bottom = iterator->bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:Display_Get=_Display_Get@8")
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
#include "dllmain.h"
|
||||
#include <list>
|
||||
|
||||
struct Display {
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
};
|
||||
|
||||
void Display_OnProcessAttach();
|
||||
void Display_OnProcessDetach();
|
||||
|
||||
BOOL CALLBACK Display_EnumerateProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
|
||||
+89
-58
@@ -17,79 +17,110 @@
|
||||
#pragma once
|
||||
#include "IndexerV1.h"
|
||||
|
||||
#define INDEX_OFF_0 0x00000000
|
||||
#define INDEX_OFF_1 0x10000000
|
||||
#define INDEX_OFF_2 0x20000000
|
||||
#define INDEX_OFF_3 0x30000000
|
||||
#define INDEX_OFF_4 0x40000000
|
||||
#define INDEX_OFF_5 0x50000000
|
||||
#define INDEX_OFF_6 0x60000000
|
||||
#define INDEX_OFF_7 0x70000000
|
||||
#define INDEX_OFF_8 0x80000000
|
||||
#define INDEX_OFF_9 0x90000000
|
||||
#define INDEX_OFF_A 0xA0000000
|
||||
#define INDEX_OFF_B 0xB0000000
|
||||
#define INDEX_OFF_C 0xC0000000
|
||||
#define INDEX_OFF_D 0xD0000000
|
||||
#define INDEX_OFF_E 0xE0000000
|
||||
#define INDEX_OFF_F 0xF0000000
|
||||
void IndexerV1::mark(uint32_t index, bool used) {
|
||||
uint8_t bit = index & 0x3F;
|
||||
index = index >> 6;
|
||||
|
||||
unsigned int IndexerV1::GetFreeIndex()
|
||||
{
|
||||
unsigned int index = lastAssignedIndex + 1;
|
||||
this->indexes[index] ^= (!(uint64_t)used ^ this->indexes[index]) & (1ULL << bit);
|
||||
}
|
||||
|
||||
bool foundIndex = false;
|
||||
char indexBitOffset = 0;
|
||||
bool IndexerV1::is(uint32_t index, bool used) {
|
||||
uint8_t bit = index & 0x3F;
|
||||
index = index >> 6;
|
||||
|
||||
// We use 16 offsets here to speed up the search for a free index.
|
||||
while (foundIndex == false) {
|
||||
index = index + 64;
|
||||
return (!!(this->indexes[index] & (1ULL << bit)) == used);
|
||||
}
|
||||
|
||||
uint64_t toCheck = this->indexes[index >> 6];
|
||||
for (indexBitOffset = 0; indexBitOffset < 64; indexBitOffset++) {
|
||||
if ((toCheck & (1ULL << indexBitOffset)) == false) {
|
||||
foundIndex = true;
|
||||
uint32_t IndexerV1::get() {
|
||||
bool hasFoundIndex = false;
|
||||
uint32_t foundIndex = 0;
|
||||
|
||||
// Our search begins and ends at lastAssignedIndex.
|
||||
for (uint32_t indexOffset = 0; indexOffset <= INDEXER_INDEXES; indexOffset++) {
|
||||
uint32_t index = (lastAssignedIndex >> 6) + indexOffset;
|
||||
uint8_t bit = 0;
|
||||
|
||||
uint64_t checkValue = this->indexes[index];
|
||||
for (uint8_t bit = 0; bit < 64; bit++) {
|
||||
if (this->is((index << 6) + bit, false)) {
|
||||
hasFoundIndex = true;
|
||||
foundIndex = (index << 6) + bit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
index = index + indexBitOffset;
|
||||
|
||||
// Mark Index as in use.
|
||||
this->indexes[index >> 6] |= 1ULL << indexBitOffset;
|
||||
lastAssignedIndex = index;
|
||||
|
||||
return lastAssignedIndex;
|
||||
if (hasFoundIndex) {
|
||||
this->mark(foundIndex, true);
|
||||
return foundIndex;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void IndexerV1::MarkFreeIndex(int index)
|
||||
{
|
||||
unsigned short bitFlip = index % 64;
|
||||
uint32_t IndexerV1::count(bool used) {
|
||||
uint32_t amount = 0;
|
||||
|
||||
// Mark index as unused.
|
||||
this->indexes[index >> 6] &= ~(1ULL << bitFlip);
|
||||
for (uint32_t index = 0; index <= INDEXER_INDEXES; index++) {
|
||||
uint8_t bit = 0;
|
||||
|
||||
uint64_t checkValue = this->indexes[index];
|
||||
if (checkValue == !(uint64_t)!used) {
|
||||
amount += 64;
|
||||
} else {
|
||||
for (uint8_t bit = 0; bit < 64; bit++) {
|
||||
amount += this->is((index << 6) + bit, used);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
DLL_EXPORT void* IndexerV1_Create() {
|
||||
IndexerV1* indexer = new IndexerV1();
|
||||
return indexer;
|
||||
DLL_METHOD IndexerV1* DLL_CALL BU_IndexerV1_Create() {
|
||||
return new IndexerV1();
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV1_Create=_IndexerV1_Create@0")
|
||||
|
||||
DLL_EXPORT int IndexerV1_GetFreeIndex(uint32_t* indexerPtr) {
|
||||
IndexerV1* indexer = (IndexerV1*)indexerPtr;
|
||||
return indexer->GetFreeIndex();
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV1_GetFreeIndex=_IndexerV1_GetFreeIndex@4")
|
||||
|
||||
DLL_EXPORT void IndexerV1_MarkFreeIndex(uint32_t* indexerPtr, uint32_t Index) {
|
||||
IndexerV1* indexer = (IndexerV1*)indexerPtr;
|
||||
indexer->MarkFreeIndex(Index);
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV1_MarkFreeIndex=_IndexerV1_MarkFreeIndex@8")
|
||||
|
||||
DLL_EXPORT void IndexerV1_Destroy(uint32_t* indexerPtr) {
|
||||
IndexerV1* indexer = (IndexerV1*)indexerPtr;
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_Destroy(IndexerV1* indexer) {
|
||||
delete indexer;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV1_Destroy=_IndexerV1_Destroy@4")
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_Mark(IndexerV1* indexer, uint32_t index, uint32_t used) {
|
||||
indexer->mark(index, used != 0);
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_MarkFree(IndexerV1* indexer, uint32_t index) {
|
||||
indexer->mark(index, false);
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_MarkUsed(IndexerV1* indexer, uint32_t index) {
|
||||
indexer->mark(index, true);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_Is(IndexerV1* indexer, uint32_t index, uint32_t used) {
|
||||
return indexer->is(index, used != 0);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_IsFree(IndexerV1* indexer, uint32_t index) {
|
||||
return indexer->is(index, false);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_IsUsed(IndexerV1* indexer, uint32_t index) {
|
||||
return indexer->is(index, true);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_Get(IndexerV1* indexer) {
|
||||
return indexer->get();
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_Count(IndexerV1* indexer, uint32_t used) {
|
||||
return indexer->count(used != 0);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_CountFree(IndexerV1* indexer) {
|
||||
return indexer->count(false);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_CountUsed(IndexerV1* indexer) {
|
||||
return indexer->count(true);
|
||||
}
|
||||
|
||||
+31
-4
@@ -20,15 +20,42 @@
|
||||
#include "dllmain.h"
|
||||
|
||||
// 67108864 = 2 ^ 32 / 64
|
||||
#define INDEXER_INDEXES 67108864
|
||||
#define INDEXER_INDEXES 67108864 //pow(2,32) / 64
|
||||
|
||||
/** Indexer structure helps with getting unique, unused Indexes (Ids).
|
||||
* Doing this natively would be too slow, so I'm using a DLL for this.
|
||||
*/
|
||||
struct IndexerV1 {
|
||||
uint64_t indexes[67108864];
|
||||
uint64_t indexes[INDEXER_INDEXES];
|
||||
uint32_t lastAssignedIndex;
|
||||
|
||||
unsigned int GetFreeIndex();
|
||||
void MarkFreeIndex(int index);
|
||||
void mark(uint32_t index, bool used);
|
||||
bool is(uint32_t index, bool used);
|
||||
uint32_t get();
|
||||
uint32_t count(bool used);
|
||||
};
|
||||
|
||||
DLL_METHOD IndexerV1* DLL_CALL BU_IndexerV1_Create();
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Create=_BU_IndexerV1_Create@0")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_Destroy(IndexerV1* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Destroy=_BU_IndexerV1_Destroy@4")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_Mark(IndexerV1* indexer, uint32_t used, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Mark=_BU_IndexerV1_Mark@12")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_MarkFree(IndexerV1* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_MarkFree=_BU_IndexerV1_MarkFree@8")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV1_MarkUsed(IndexerV1* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_MarkUsed=_BU_IndexerV1_MarkUsed@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_Is(IndexerV1* indexer, uint32_t index, uint32_t used);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Is=_BU_IndexerV1_Is@12")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_IsFree(IndexerV1* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_IsFree=_BU_IndexerV1_IsFree@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_IsUsed(IndexerV1* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_IsUsed=_BU_IndexerV1_IsUsed@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_Get(IndexerV1* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Get=_BU_IndexerV1_Get@4")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_Count(IndexerV1* indexer, uint32_t used);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Count=_BU_IndexerV1_Count@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_CountFree(IndexerV1* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_CountFree=_BU_IndexerV1_CountFree@4")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV1_CountUsed(IndexerV1* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV1_CountUsed=_BU_IndexerV1_CountUsed@4")
|
||||
|
||||
+131
-94
@@ -1,101 +1,119 @@
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "IndexerV2.h"
|
||||
|
||||
IndexerV2::IndexerV2() {
|
||||
this->range.reserve(32);
|
||||
}
|
||||
|
||||
|
||||
IndexerV2::~IndexerV2() {
|
||||
this->range.clear();
|
||||
}
|
||||
|
||||
uint32_t IndexerV2::GetIndex() {
|
||||
uint32_t index = 0;
|
||||
|
||||
void IndexerV2::mark(uint32_t index, bool used) {
|
||||
if (this->range.size() == 0) {
|
||||
this->range.push_back(IndexerV2Range(0, 0));
|
||||
if (used == true)
|
||||
this->range.push_back(IndexerV2Range(index, index));
|
||||
} else {
|
||||
auto range = this->range[0];
|
||||
|
||||
if (range.min > 0) {
|
||||
index = --range.min;
|
||||
} else {
|
||||
index = ++range.max;
|
||||
}
|
||||
|
||||
// Combine the next and current element if we need to.
|
||||
if (this->range.size() > 1) {
|
||||
auto rangeNext = this->range[1];
|
||||
|
||||
if (rangeNext.min == (index + 1)) {
|
||||
uint32_t newMin, newMax;
|
||||
newMin = range.min;
|
||||
newMax = rangeNext.max;
|
||||
|
||||
this->range.erase(this->range.begin(), this->range.begin() + 1);
|
||||
this->range.insert(this->range.begin(), IndexerV2Range(newMin, newMax));
|
||||
auto iter = this->range.begin();
|
||||
for (auto iter = this->range.begin(); iter != this->range.end(); iter++) {
|
||||
if (used) {
|
||||
if ((index + 1) == iter->min) {
|
||||
iter->min--;
|
||||
break;
|
||||
} else if ((index - 1) == iter->max) {
|
||||
iter->max++;
|
||||
if ((iter + 1) != this->range.end() && iter->max == (iter + 1)->min) {
|
||||
(iter + 1)->min = iter->min;
|
||||
this->range.erase(iter);
|
||||
}
|
||||
break;
|
||||
} else if (index < iter->min) {
|
||||
this->range.insert(iter, IndexerV2Range(index, index));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (index >= iter->min && index <= iter->max) {
|
||||
this->range.insert(iter - 1, IndexerV2Range(iter->min, index - 1));
|
||||
this->range.insert(iter + 1, IndexerV2Range(index + 1, iter->max));
|
||||
this->range.erase(iter); break;
|
||||
} else if (index == iter->min) {
|
||||
iter->min++;
|
||||
if (iter->min == iter->max)
|
||||
this->range.erase(iter);
|
||||
break;
|
||||
} else if (index == iter->max) {
|
||||
iter->max--;
|
||||
if (iter->min == iter->max)
|
||||
this->range.erase(iter);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
void IndexerV2::MarkIndex(uint32_t index) {
|
||||
IndexerV2Range* rangePtr;
|
||||
uint32_t rangePtrPos;
|
||||
|
||||
uint32_t rangeSize = this->range.size();
|
||||
for (uint32_t rangePos = 0; rangePos < rangeSize; rangePos++) {
|
||||
auto range = this->range[rangePos];
|
||||
|
||||
if (index >= range.min && index <= range.max) {
|
||||
rangePtr = ⦥
|
||||
rangePtrPos = rangePos;
|
||||
bool IndexerV2::is(uint32_t index, bool used) {
|
||||
bool isUsed = false;
|
||||
for (auto iter = this->range.begin(); iter != this->range.end(); iter++) {
|
||||
if (index >= iter->min && index <= iter->max) {
|
||||
isUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Temporarily store the values needed for swapping.
|
||||
uint32_t leftMin, leftMax, rightMin, rightMax;
|
||||
leftMin = rangePtr->min; leftMax = index - 1;
|
||||
rightMin = index + 1; rightMax = rangePtr->max;
|
||||
|
||||
// Due to us doing this instead of push_back, our vector is always sorted.
|
||||
auto rangeIter = this->range.begin() + rangePtrPos;
|
||||
this->range.erase(rangeIter);
|
||||
this->range.insert(rangeIter, IndexerV2Range(leftMin, leftMax));
|
||||
this->range.insert(rangeIter + 1, IndexerV2Range(rightMin, rightMax));
|
||||
return (isUsed == used);
|
||||
}
|
||||
|
||||
bool IndexerV2::IsFree(uint32_t index) {
|
||||
uint32_t rangeSize = this->range.size();
|
||||
for (uint32_t rangePos = 0; rangePos < rangeSize; rangePos++) {
|
||||
auto range = this->range[rangePos];
|
||||
if (index >= range.min && index <= range.max)
|
||||
return false;
|
||||
uint32_t IndexerV2::get() {
|
||||
if (this->range.size() == 0) {
|
||||
this->range.push_back(IndexerV2Range(0, 0));
|
||||
return 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
// We only need to check the first element to get a new free index.
|
||||
std::vector<IndexerV2Range>::iterator iter = this->range.begin();
|
||||
if (iter->min > 0) {
|
||||
return --iter->min;
|
||||
} else {
|
||||
if (iter->max == UINT32_MAX)
|
||||
return UINT32_MAX;
|
||||
|
||||
uint32_t index = ++iter->max;
|
||||
|
||||
// Check if we can combine this element with the next one.
|
||||
std::vector<IndexerV2Range>::iterator iterN = this->range.begin() + 1;
|
||||
if ((iterN != this->range.end()) && iterN->min == iter->max) {
|
||||
iter->max = iterN->max;
|
||||
this->range.erase(iterN);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
bool IndexerV2::IsUsed(uint32_t index) {
|
||||
return !IsFree(index);
|
||||
uint32_t IndexerV2::count(bool used) {
|
||||
uint32_t amount = 0;
|
||||
for (auto iter = this->range.begin(); iter != this->range.end(); iter++) {
|
||||
amount += iter->max - iter->min;
|
||||
}
|
||||
return (used ? UINT32_MAX - amount : amount);
|
||||
}
|
||||
|
||||
IndexerV2::IndexerV2Range::IndexerV2Range(uint32_t min, uint32_t max) {
|
||||
@@ -103,32 +121,51 @@ IndexerV2::IndexerV2Range::IndexerV2Range(uint32_t min, uint32_t max) {
|
||||
this->max = max;
|
||||
}
|
||||
|
||||
DLL_EXPORT void* IndexerV2_Create() {
|
||||
IndexerV2* indexerPtr = new IndexerV2();
|
||||
return indexerPtr;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV2_Create=_IndexerV2_Create@0")
|
||||
|
||||
DLL_EXPORT void IndexerV2_Destroy(uint32_t indexerIntPtr) {
|
||||
IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr;
|
||||
delete indexerPtr;
|
||||
DLL_METHOD IndexerV2* DLL_CALL BU_IndexerV2_Create() {
|
||||
return new IndexerV2();
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV2_Destroy=_IndexerV2_Destroy@4")
|
||||
|
||||
DLL_EXPORT uint32_t IndexerV2_GetIndex(uint32_t indexerIntPtr) {
|
||||
IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr;
|
||||
return indexerPtr->GetIndex();
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_Destroy(IndexerV2* indexer) {
|
||||
delete indexer;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV2_GetIndex=_IndexerV2_GetIndex@4")
|
||||
|
||||
DLL_EXPORT uint32_t IndexerV2_IsFree(uint32_t indexerIntPtr, uint32_t index) {
|
||||
IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr;
|
||||
return indexerPtr->IsFree(index);
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_Mark(IndexerV2* indexer, uint32_t used, uint32_t index) {
|
||||
indexer->mark(index, used != 0);
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV2_IsFree=_IndexerV2_IsFree@8")
|
||||
|
||||
DLL_EXPORT uint32_t IndexerV2_IsUsed(uint32_t indexerIntPtr, uint32_t index) {
|
||||
IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr;
|
||||
return indexerPtr->IsUsed(index);
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_MarkFree(IndexerV2* indexer, uint32_t index) {
|
||||
indexer->mark(index, false);
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_MarkUsed(IndexerV2* indexer, uint32_t index) {
|
||||
indexer->mark(index, true);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_Is(IndexerV2* indexer, uint32_t index, uint32_t used) {
|
||||
return indexer->is(index, used != 0);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_IsFree(IndexerV2* indexer, uint32_t index) {
|
||||
return indexer->is(index, false);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_IsUsed(IndexerV2* indexer, uint32_t index) {
|
||||
return indexer->is(index, true);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_Get(IndexerV2* indexer) {
|
||||
return indexer->get();
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_Count(IndexerV2* indexer, uint32_t used) {
|
||||
return indexer->count(used != 0);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_CountFree(IndexerV2* indexer) {
|
||||
return indexer->count(false);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_CountUsed(IndexerV2* indexer) {
|
||||
return indexer->count(true);
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:IndexerV2_IsUsed=_IndexerV2_IsUsed@8")
|
||||
|
||||
+45
-20
@@ -1,19 +1,19 @@
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
#include "dllmain.h"
|
||||
#include <vector>
|
||||
@@ -23,11 +23,11 @@ class IndexerV2 {
|
||||
IndexerV2();
|
||||
~IndexerV2();
|
||||
|
||||
uint32_t GetIndex();
|
||||
void MarkIndex(uint32_t index);
|
||||
void mark(uint32_t index, bool used);
|
||||
bool is(uint32_t index, bool used);
|
||||
uint32_t get();
|
||||
uint32_t count(bool used);
|
||||
|
||||
bool IsFree(uint32_t index);
|
||||
bool IsUsed(uint32_t index);
|
||||
private:
|
||||
struct IndexerV2Range {
|
||||
uint32_t min, max;
|
||||
@@ -38,3 +38,28 @@ class IndexerV2 {
|
||||
std::vector<IndexerV2Range> range;
|
||||
};
|
||||
|
||||
DLL_METHOD IndexerV2* DLL_CALL BU_IndexerV2_Create();
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_Create=_BU_IndexerV2_Create@0")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_Destroy(IndexerV2* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_Destroy=_BU_IndexerV2_Destroy@4")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_Mark(IndexerV2* indexer, uint32_t used, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_Mark=_BU_IndexerV2_Mark@12")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_MarkFree(IndexerV2* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_MarkFree=_BU_IndexerV2_MarkFree@8")
|
||||
DLL_METHOD void DLL_CALL BU_IndexerV2_MarkUsed(IndexerV2* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_MarkUsed=_BU_IndexerV2_MarkUsed@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_Is(IndexerV2* indexer, uint32_t index, uint32_t used);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_Is=_BU_IndexerV2_Is@12")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_IsFree(IndexerV2* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_IsFree=_BU_IndexerV2_IsFree@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_IsUsed(IndexerV2* indexer, uint32_t index);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_IsUsed=_BU_IndexerV2_IsUsed@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_Get(IndexerV2* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_Get=_BU_IndexerV2_Get@4")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_Count(IndexerV2* indexer, uint32_t used);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_Count=_BU_IndexerV2_Count@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_CountFree(IndexerV2* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_CountFree=_BU_IndexerV2_CountFree@4")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_IndexerV2_CountUsed(IndexerV2* indexer);
|
||||
#pragma comment(linker, "/EXPORT:BU_IndexerV2_CountUsed=_BU_IndexerV2_CountUsed@4")
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
|
||||
std::list<WindowUserData>* WindowMessageHandler_List;
|
||||
|
||||
void WindowMessageHandler_OnProcessAttach() {
|
||||
void BU_WindowMessageHandler_OnProcessAttach() {
|
||||
WindowMessageHandler_List = new std::list<WindowUserData>();
|
||||
}
|
||||
|
||||
void WindowMessageHandler_OnProcessDetach() {
|
||||
void BU_WindowMessageHandler_OnProcessDetach() {
|
||||
for (auto iterator = WindowMessageHandler_List->begin(), end = WindowMessageHandler_List->end(); iterator != end; iterator++) {
|
||||
WindowMessageHandler_Uninstall(iterator->hwnd);
|
||||
BU_WindowMessageHandler_Uninstall(iterator->hwnd);
|
||||
}
|
||||
|
||||
WindowMessageHandler_List->clear();
|
||||
delete WindowMessageHandler_List;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
LRESULT CALLBACK BU_WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
switch (uMsg) {
|
||||
@@ -60,57 +60,50 @@ LRESULT CALLBACK WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wPa
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT void WindowMessageHandler_Install(HWND hwnd) {
|
||||
if (hwnd) {
|
||||
WindowUserData* UserData = new WindowUserData;
|
||||
ZeroMemory(UserData, sizeof(UserData));
|
||||
UserData->oWindowProcedure = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)&WindowMessageHandler_Procedure);
|
||||
UserData->oUserData = SetWindowLong(hwnd, GWL_USERDATA, (LONG)UserData);
|
||||
DLL_METHOD void DLL_CALL BU_WindowMessageHandler_Install(HWND hwnd)
|
||||
{
|
||||
WindowUserData* UserData = new WindowUserData;
|
||||
ZeroMemory(UserData, sizeof(UserData));
|
||||
UserData->oWindowProcedure = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)&BU_WindowMessageHandler_Procedure);
|
||||
UserData->oUserData = SetWindowLong(hwnd, GWL_USERDATA, (LONG)UserData);
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_WindowMessageHandler_Uninstall(HWND hwnd)
|
||||
{
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
SetWindowLong(hwnd, GWL_USERDATA, UserData->oUserData);
|
||||
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)(UserData->oWindowProcedure));
|
||||
delete UserData;
|
||||
}
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:WindowMessageHandler_Install=_WindowMessageHandler_Install@4")
|
||||
|
||||
DLL_EXPORT void WindowMessageHandler_Uninstall(HWND hwnd) {
|
||||
if (hwnd) {
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
SetWindowLong(hwnd, GWL_USERDATA, UserData->oUserData);
|
||||
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)(UserData->oWindowProcedure));
|
||||
delete UserData;
|
||||
}
|
||||
DLL_METHOD uint32_t DLL_CALL BU_WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point)
|
||||
{
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
int toReturn = UserData->WindowWasResized;
|
||||
point->x = UserData->WindowClientWidth;
|
||||
point->y = UserData->WindowClientHeight;
|
||||
UserData->WindowWasResized = false;
|
||||
return toReturn;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:WindowMessageHandler_Uninstall=_WindowMessageHandler_Uninstall@4")
|
||||
|
||||
DLL_EXPORT int WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point) {
|
||||
if (hwnd) {
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
int toReturn = UserData->WindowWasResized;
|
||||
point->x = UserData->WindowClientWidth;
|
||||
point->y = UserData->WindowClientHeight;
|
||||
UserData->WindowWasResized = false;
|
||||
return toReturn;
|
||||
}
|
||||
DLL_METHOD uint32_t DLL_CALL BU_WindowMessageHandler_Message_Destroy(HWND hwnd)
|
||||
{
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
int toReturn = UserData->DestroyCount;
|
||||
UserData->DestroyCount = 0;
|
||||
return toReturn;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:WindowMessageHandler_Message_Resize=_WindowMessageHandler_Message_Resize@8")
|
||||
|
||||
DLL_EXPORT int WindowMessageHandler_Message_Destroy(HWND hwnd) {
|
||||
if (hwnd) {
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
int toReturn = UserData->DestroyCount;
|
||||
UserData->DestroyCount = 0;
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:WindowMessageHandler_Message_Destroy=_WindowMessageHandler_Message_Destroy@4")
|
||||
|
||||
DLL_EXPORT int WindowMessageHandler_Message_Close(HWND hwnd) {
|
||||
DLL_METHOD uint32_t DLL_CALL BU_WindowMessageHandler_Message_Close(HWND hwnd)
|
||||
{
|
||||
if (hwnd) {
|
||||
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
if (UserData) {
|
||||
@@ -121,5 +114,5 @@ DLL_EXPORT int WindowMessageHandler_Message_Close(HWND hwnd) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:WindowMessageHandler_Message_Close=_WindowMessageHandler_Message_Close@4")
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,17 @@ struct WindowUserData {
|
||||
};
|
||||
|
||||
|
||||
void WindowMessageHandler_OnProcessAttach();
|
||||
void WindowMessageHandler_OnProcessDetach();
|
||||
void BU_WindowMessageHandler_OnProcessAttach();
|
||||
void BU_WindowMessageHandler_OnProcessDetach();
|
||||
LRESULT CALLBACK BU_WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
LRESULT CALLBACK WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
DLL_EXPORT void WindowMessageHandler_Install(HWND hwnd);
|
||||
DLL_EXPORT void WindowMessageHandler_Uninstall(HWND hwnd);
|
||||
DLL_METHOD void DLL_CALL BU_WindowMessageHandler_Install(HWND hwnd);
|
||||
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Install=_BU_WindowMessageHandler_Install@4")
|
||||
DLL_METHOD void DLL_CALL BU_WindowMessageHandler_Uninstall(HWND hwnd);
|
||||
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Uninstall=_BU_WindowMessageHandler_Uninstall@4")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point);
|
||||
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Resize=_BU_WindowMessageHandler_Message_Resize@8")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_WindowMessageHandler_Message_Destroy(HWND hwnd);
|
||||
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Destroy=_BU_WindowMessageHandler_Message_Destroy@4")
|
||||
DLL_METHOD uint32_t DLL_CALL BU_WindowMessageHandler_Message_Close(HWND hwnd);
|
||||
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Close=_BU_WindowMessageHandler_Message_Close@4")
|
||||
Reference in New Issue
Block a user