This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththreads.h
82 lines (65 loc) · 1.77 KB
/
threads.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include "konnekt_sdk.h"
#include "main.h"
#include <Stamina\Thread.h>
namespace Konnekt {
extern Stamina::Thread mainThread;
struct sIMTS {
unsigned int msgID;
unsigned int receiver;
int retVal;
HANDLE waitEvent;
sIMessage_base * msg;
// sIMessage temp;
// char temp [2000];
int inMessage; // czy jest w wiadomosci
int plugID; // identyfikator wtyczki odbierajacej . 0 - Core
#if defined(__DEBUG)
struct {int id , p1 , p2 , size , sender , rcvr;} debug;
#endif
void set (sIMessage_base * _msg);
void enterMsg (sIMessage_base * _msg , unsigned int _plugID);
void leaveMsg ();
sIMTS() {msg = 0; inMessage=0; msgID = 0; receiver = 0; retVal = 0; waitEvent = 0; plugID = 0;}
~sIMTS() {}
class cUserThread * Thread;
};
struct cDLLTempBuffer {
void * buff;
unsigned int size;
void * GetBuffer(unsigned int wantSize) {
if (wantSize > this->size) {
//if (buff) free(buff);
buff = realloc(buff, wantSize);
this->size = wantSize;
}
return buff;
}
cDLLTempBuffer() {buff = 0; size = 0;}
~cDLLTempBuffer() {if (buff) free(buff);}
};
class cUserThread {
public:
sIMTS lastIM;
COLORREF color;
CStdString name;
struct {
int code;
int position;
} error;
map <unsigned int , cDLLTempBuffer> Buffers;
void setError(int code) {
error.code = code;
error.position=lastIM.inMessage;
}
cUserThread();
~cUserThread();
};
extern cTLS<cUserThread> TLSU;
typedef map <DWORD , HANDLE> tThreads;
extern tThreads threads;
extern Stamina::CriticalSection threadsCS;
VOID CALLBACK IMTSRecaller(ULONG_PTR param);
int RecallIMTS(sIMTS & _im , HANDLE thread , bool wait);
extern Stamina::oThreadRunner threadRunner;
};