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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
{
Miranda IM: the free IM client for Microsoft* Windows*
Copyright 2000-2008 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
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 General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
{$IFNDEF M_CORE}
{$DEFINE M_CORE}
const
CoreDLL = 'mir_core.mir';
AppDLL = 'mir_app.mir';
///////////////////////////////////////////////////////////////////////////////
// command line support
// Parse ptszCmdLine. it must NOT be a constant (content will be patched)
procedure CmdLine_Parse(ptszCmdLine:PWideChar); stdcall;
external CoreDLL name 'CmdLine_Parse';
function CmdLine_GetOption(ptszParameter:PWideChar):PWideChar; stdcall;
external CoreDLL name 'CmdLine_GetOption';
///////////////////////////////////////////////////////////////////////////////
// database functions
const
DBVT_ASIS = 0; // in, for db_get_s, to not translate output value
DBVT_DELETED = 0; // setting got deleted, no values are valid
DBVT_BYTE = 1; // bVal, cVal are valid
DBVT_WORD = 2; // wVal, sVal are valid
DBVT_DWORD = 4; // dVal, lVal are valid
DBVT_ASCIIZ = 255; // pszVal is valid
DBVT_BLOB = 254; // cpbVal and pbVal are valid
DBVT_UTF8 = 253; // pszVal is valid
DBVT_WCHAR = 252; // pszVal is valid
DBVTF_VARIABLELENGTH = $80; // ?
type
PMCONTACT = ^TMCONTACT;
TMCONTACT = dword;
const
INVALID_CONTACT_ID = TMCONTACT(-1);
type
TMEVENT = dword;
///////////////////////////////////////////////////////////////////////////////
// events, hooks & services
const
MAXMODULELABELLENGTH = 64;
type
TMIRANDAHOOK = function(wParam: WPARAM; lParam: LPARAM): int; cdecl;
TMIRANDAHOOKPARAM = function(wParam: WPARAM; lParam,lParam1: LPARAM): int; cdecl;
TMIRANDAHOOKOBJ = function(ptr:pointer;wParam:WPARAM;lParam:LPARAM): int; cdecl;
TMIRANDAHOOKOBJPARAM = function(ptr:pointer;wParam:WPARAM;lParam,lParam1: LPARAM): int; cdecl;
TMIRANDASERVICE = function(wParam: WPARAM; lParam: LPARAM): int_ptr; cdecl;
TMIRANDASERVICEPARAM = function(wParam:WPARAM;lParam,lParam1:LPARAM):int_ptr; cdecl;
TMIRANDASERVICEOBJ = function(ptr:pointer;wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
TMIRANDASERVICEOBJPARAM = function(ptr:pointer;wParam:WPARAM;lParam,lParam1:LPARAM):int_ptr; cdecl;
const
{$IFDEF WIN64}
CALLSERVICE_NOTFOUND = int_ptr($8000000000000000);
{$ELSE}
CALLSERVICE_NOTFOUND = int_ptr($80000000);
{$ENDIF}
function CreateHookableEvent(const name: PAnsiChar): THANDLE; stdcall;
external CoreDLL name 'CreateHookableEvent';
function DestroyHookableEvent(hEvent:THANDLE): int; stdcall;
external CoreDLL name 'DestroyHookableEvent';
function SetHookDefaultForHookableEvent(hEvent:THANDLE; pfnHook:TMIRANDAHOOK):int; stdcall;
external CoreDLL name 'SetHookDefaultForHookableEvent';
function CallPluginEventHook(hInst:HINST; hEvent:THANDLE; wParam:WPARAM; lParam:LPARAM):int; stdcall;
external CoreDLL name 'CallPluginEventHook';
function NotifyEventHooks(hEvent:THANDLE; wParam:WPARAM; lParam:LPARAM): int; stdcall;
external CoreDLL name 'NotifyEventHooks';
function NotifyFastHook(hEvent:THANDLE; wParam:WPARAM; lParam:LPARAM): int; stdcall;
external CoreDLL name 'NotifyFastHook';
function HookEvent(const name:PAnsiChar; hookProc: TMIRANDAHOOK): THANDLE; stdcall;
external CoreDLL name 'HookEvent';
function HookEventParam(const name:PAnsiChar; hookProc:TMIRANDAHOOKPARAM;lParam:LPARAM):THANDLE; stdcall;
external CoreDLL name 'HookEventParam';
function HookEventObj(const name:PAnsiChar; hookProc:TMIRANDAHOOKOBJ;ptr:pointer):THANDLE; stdcall;
external CoreDLL name 'HookEventObj';
function HookEventObjParam(const name:PAnsiChar; hookProc:TMIRANDAHOOKOBJPARAM;ptr:pointer;lParam:LPARAM):THANDLE; stdcall;
external CoreDLL name 'HookEventObjParam';
function HookEventMessage(const name:PAnsiChar; Wnd:HWND; wMsg:uint):THANDLE; stdcall;
external CoreDLL name 'HookEventMessage';
function UnhookEvent(hHook:THANDLE): int; stdcall;
external CoreDLL name 'UnhookEvent';
procedure KillObjectEventHooks(var ptr); stdcall;
external CoreDLL name 'KillObjectEventHooks';
procedure KillModuleEventHooks(pModule:HINST); stdcall;
external CoreDLL name 'KillModuleEventHooks';
function CreateServiceFunction(const name:PAnsiChar; serviceProc:TMIRANDASERVICE): THANDLE; stdcall;
external CoreDLL name 'CreateServiceFunction';
function CreateServiceFunctionParam(const name:PAnsiChar; serviceProc:TMIRANDASERVICEPARAM;lParam:LPARAM):THANDLE; stdcall;
external CoreDLL name 'CreateServiceFunctionParam';
function CreateServiceFunctionObj(const name:PAnsiChar; serviceProc:TMIRANDASERVICEOBJ;ptr:pointer):THANDLE; stdcall;
external CoreDLL name 'CreateServiceFunctionObj';
function CreateServiceFunctionObjParam(const name:PAnsiChar; serviceProc:TMIRANDASERVICEOBJPARAM;ptr:pointer;lParam:LPARAM):THANDLE; stdcall;
external CoreDLL name 'CreateServiceFunctionObjParam';
function DestroyServiceFunction(hService:THANDLE):int; stdcall;
external CoreDLL name 'DestroyServiceFunction';
function ServiceExists(const name:PAnsiChar):int; stdcall;
external CoreDLL name 'ServiceExists';
function CallService(const name:PAnsiChar; wParam:WPARAM; lParam:LPARAM):int_ptr; stdcall;
external CoreDLL name 'CallService';
function CallServiceSync(const name:PAnsiChar; wParam:WPARAM; lParam:LPARAM):int_ptr; stdcall;
external CoreDLL name 'CallServiceSync';
function CallFunctionAsync(ptr1,ptr2:pointer):int; stdcall;
external CoreDLL name 'CallFunctionAsync';
procedure KillModuleServices(hInst:HINST); stdcall;
external CoreDLL name 'KillModuleServices';
procedure KillObjectServices(var ptr); stdcall;
external CoreDLL name 'KillObjectServices';
function CallContactService(hContact:TMCONTACT;const name:PAnsiChar;wParam:WPARAM;lParam:LPARAM):int_ptr; stdcall;
external AppDLL name 'CallContactService';
function CallProtoService(const szModule:PAnsiChar;const szService:PAnsiChar;wParam:WPARAM;lParam:LPARAM):int_ptr; stdcall;
external AppDLL name 'CallProtoService';
///////////////////////////////////////////////////////////////////////////////
// http
// returned result must be freed using mir_free()
function mir_urlEncode(url:PAnsiChar): PAnsiChar; stdcall;
external CoreDLL name 'mir_urlEncode';
///////////////////////////////////////////////////////////////////////////////
// exceptions
type
PEXCEPTION_POINTERS = ^EXCEPTION_POINTERS;
pfnExceptionFilter = function(code:dword; info:PEXCEPTION_POINTERS):dword; cdecl;
function GetExceptionFilter():pfnExceptionFilter; stdcall;
external CoreDLL name 'GetExceptionFilter';
function SetExceptionFilter(pMirandaExceptFilter:pfnExceptionFilter):pfnExceptionFilter; stdcall;
external CoreDLL name 'SetExceptionFilter';
///////////////////////////////////////////////////////////////////////////////
// icons support
type
pIconItem = ^tIconItem;
tIconItem = record
szDescr:PAnsiChar;
szName :PAnsiChar;
defIconID,
size :int;
hIcolib:THANDLE;
end;
tagIconItem = tIconItem;
pIconItemW = ^tIconItemW;
tIconItemW = record
szDescr:PWideChar;
szName :PAnsiChar;
defIconID,
size :int;
hIcolib:THANDLE;
end;
tagIconItemW = tIconItemW;
procedure mir_Icon_Register(hInst:HINST; const szSection:PAnsiChar; pIcons:pIconItem;
iCount:size_t; prefix:PAnsiChar; hLangpack:int=0); stdcall;
external CoreDLL name 'Icon_Register';
procedure mir_Icon_RegisterW(hInst:HINST; const szSection:PWideChar; pIcons:pIconItemW;
iCount:size_t; prefix:PAnsiChar; hLangpack:int=0); stdcall;
external CoreDLL name 'Icon_RegisterT';
///////////////////////////////////////////////////////////////////////////////
// language packs support
const
LANG_UNICODE = $1000;
procedure Langpack_SortDuplicates(); stdcall;
external CoreDLL name 'Langpack_SortDuplicates';
function Langpack_GetDefaultCodePage():int; stdcall;
external CoreDLL name 'Langpack_GetDefaultCodePage';
function Langpack_GetDefaultLocale():int; stdcall;
external CoreDLL name 'Langpack_GetDefaultLocale';
function Langpack_PcharToTchar(const pszStr:PAnsiChar):PWideChar; stdcall;
external CoreDLL name 'Langpack_PcharToTchar';
function LoadLangPackModule():int; stdcall;
external CoreDLL name 'LoadLangPackModule';
function LoadLangPack(const szLangPack:PWideChar):int; stdcall;
external CoreDLL name 'LoadLangPack';
procedure ReloadLangpack(pszStr:PWideChar); stdcall;
external CoreDLL name 'ReloadLangpack';
function TranslateA_LP(const str:PAnsiChar; hLang:int):PAnsiChar; stdcall;
external CoreDLL name 'TranslateA_LP';
function TranslateW_LP(const str:PWideChar; hLang:int):PWideChar; stdcall;
external CoreDLL name 'TranslateW_LP';
procedure TranslateMenu_LP(hMenu:HMENU; hLang:int); stdcall;
external CoreDLL name 'TranslateMenu_LP';
procedure TranslateDialog_LP(hDlg:HWND; hLang:int); stdcall;
external CoreDLL name 'TranslateDialog_LP';
function mir_hash(const key:pointer; len:uint):uint; stdcall;
external CoreDLL name 'mir_hash';
///////////////////////////////////////////////////////////////////////////////
// lists
type
TFSortFunc = function (para1:pointer; para2:pointer):int;cdecl;
{
// Assumes first 32 bit value of the data is the numeric key
// and uses it to perform sort/search operations, this results
// in much better performance as no compare function calls needed
// Incredibly useful for Hash Tables
}
const
NumericKeySort = {TFSortFunc}(pointer(-1));
HandleKeySort = {TFSortFunc}(pointer(-2));
PtrKeySort = {TFSortFunc}(pointer(-3));
type
PSortedList = ^TSortedList;
TSortedList = record
items : array of pointer;
realCount: int;
limit : int;
increment: int;
sortFunc : TFSortFunc;
end;
// BUGGED with limit <> 0. list pointer must befreed by mir_free
function List_Create(limit:int; increment:int):PSortedList;stdcall;
external CoreDLL name 'List_Create';
procedure List_Destroy(list:PSortedList);stdcall;
external CoreDLL name 'List_Destroy';
function List_Find(list:PSortedList; value:pointer):pointer;stdcall;
external CoreDLL name 'List_Find';
function List_GetIndex(list:PSortedList; value:pointer; index:Pint):int;stdcall;
external CoreDLL name 'List_GetIndex';
function List_IndexOf(list:PSortedList; value:pointer):int;stdcall;
external CoreDLL name 'List_IndexOf';
function List_Insert(list:PSortedList; value:pointer; index:int):int;stdcall;
external CoreDLL name 'List_Insert';
function List_InsertPtr(list:PSortedList; p:pointer):int;stdcall;
external CoreDLL name 'List_InsertPtr';
function List_Remove(list:PSortedList; index:int):int;stdcall;
external CoreDLL name 'List_Remove';
function List_RemovePtr(list:PSortedList; p:pointer):int;stdcall;
external CoreDLL name 'List_RemovePtr';
procedure List_Copy(src:PSortedList; dst:PSortedList; size:size_t); stdcall;
external CoreDLL name 'List_Copy';
procedure List_ObjCopy(src:PSortedList; dst:PSortedList; size:size_t); stdcall;
external CoreDLL name 'List_ObjCopy';
///////////////////////////////////////////////////////////////////////////////
// log functions
function mir_createLog(pszName:PAnsiChar; ptszDescr, ptszFile:PWideChar; options:Cardinal):THANDLE; stdcall;
external CoreDLL name 'mir_createLog';
procedure mir_closeLog(hLogger:THANDLE); stdcall;
external CoreDLL name 'mir_closeLog';
function mir_writeLogA(hLogger:THANDLE; format:PAnsiChar):int; cdecl;
external CoreDLL name 'mir_writeLogA';
function mir_writeLogW(hLogger:THANDLE; format:PWideChar):int; cdecl;
external CoreDLL name 'mir_writeLogW';
///////////////////////////////////////////////////////////////////////////////
// md5 functions
// Define the state of the MD5 Algorithm.
type
pmir_md5_state_t = ^mir_md5_state_t;
mir_md5_state_t = record
count:array [0.. 1] of longword; // message length in bits, lsw first
abcd :array [0.. 3] of longword; // digest buffer
buf :array [0..63] of byte; // accumulate block
end;
TMD5Hash = array [0..15] of byte;
procedure mir_md5_init(pms:pmir_md5_state_t); stdcall;
external CoreDLL name 'mir_md5_init';
procedure mir_md5_append(pms:pmir_md5_state_t; const data:pbyte; nbytes:int); stdcall;
external CoreDLL name 'mir_md5_append';
procedure mir_md5_finish(pms:pmir_md5_state_t; digest:TMD5Hash); stdcall;
external CoreDLL name 'mir_md5_finish';
procedure mir_md5_hash(const data:pbyte; len:int; digest:TMD5Hash); stdcall;
external CoreDLL name 'mir_md5_hash';
///////////////////////////////////////////////////////////////////////////////
// memory functions
function mir_alloc(para1:size_t):pointer; cdecl;
external CoreDLL name 'mir_alloc';
function mir_calloc(para1:size_t):pointer; cdecl;
external CoreDLL name 'mir_calloc';
function mir_realloc(para1:pointer; para2:size_t):pointer; cdecl;
external CoreDLL name 'mir_realloc';
procedure mir_free(para1:pointer); cdecl;
external CoreDLL name 'mir_free';
function mir_strdup(const src:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'mir_strdup';
function mir_wstrdup(const src:PWideChar):PWideChar; stdcall;
external CoreDLL name 'mir_wstrdup';
function mir_strndup(const src:PAnsiChar; len:size_t):PAnsiChar; stdcall;
external CoreDLL name 'mir_strndup';
function mir_wstrndup(const src:PWideChar; len:size_t):PWideChar; stdcall;
external CoreDLL name 'mir_wstrndup';
function mir_strlen(const src:PAnsiChar):size_t; stdcall;
external CoreDLL name 'mir_strlen';
function mir_wstrlen(const src:PWideChar):size_t; stdcall;
external CoreDLL name 'mir_wstrlen';
function mir_strcpy(dst:PAnsiChar; const src:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'mir_strcpy';
function mir_wstrcpy(dst:PWideChar; const src:PWideChar):PWideChar; stdcall;
external CoreDLL name 'mir_wstrcpy';
function mir_strncpy(dst:PAnsiChar; const src:PAnsiChar; len:size_t):PAnsiChar; stdcall;
external CoreDLL name 'mir_strncpy';
function mir_wstrncpy(dst:PWideChar; const src:PWideChar; len:size_t):PWideChar; stdcall;
external CoreDLL name 'mir_wstrncpy';
function mir_strcat(dst:PAnsiChar; const src:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'mir_strcat';
function mir_wstrcat(dst:PWideChar; const src:PWideChar):PWideChar; stdcall;
external CoreDLL name 'mir_wstrcat';
function mir_strncat(dst:PAnsiChar; const src:PAnsiChar; len:size_t):PAnsiChar; stdcall;
external CoreDLL name 'mir_strncat';
function mir_wstrncat(dst:PWideChar; const src:PWideChar; len:size_t):PWideChar; stdcall;
external CoreDLL name 'mir_wstrncat';
function mir_strcmp(const p1,p2:PAnsiChar):int; stdcall;
external CoreDLL name 'mir_strcmp';
function mir_wstrcmp(const p1,p2:PWideChar):int; stdcall;
external CoreDLL name 'mir_wstrcmp';
function mir_strcmpi(const p1,p2:PAnsiChar):int; stdcall;
external CoreDLL name 'mir_strcmpi';
function mir_wstrcmpi(const p1,p2:PWideChar):int; stdcall;
external CoreDLL name 'mir_wstrcmpi';
///////////////////////////////////////////////////////////////////////////////
// modules
procedure RegisterModule(hInst:HINST); stdcall;
external CoreDLL name 'RegisterModule';
procedure UnregisterModule(hInst:HINST); stdcall;
external CoreDLL name 'UnregisterModule';
function GetInstByAddress(codePtr:pointer):HINST; stdcall;
external CoreDLL name 'GetInstByAddress';
///////////////////////////////////////////////////////////////////////////////
// print functions
function mir_snprintf(buffer:PAnsiChar;count:size_t;fmt:PAnsiChar{, ...}):int; stdcall;
external CoreDLL name 'mir_snprintf';
function mir_snwprintf(buffer:PWideChar;count:size_t;fmt:PWideChar{, ...}):int; stdcall;
external CoreDLL name 'mir_snwprintf';
function mir_vsnprintf(buffer:PAnsiChar;count:size_t;fmt:PAnsiChar;va:va_list):int; stdcall;
external CoreDLL name 'mir_vsnprintf';
function mir_vsnwprintf(buffer:PWideChar;count:size_t;fmt:PWideChar;va:va_list):int; stdcall;
external CoreDLL name 'mir_vsnwprintf';
///////////////////////////////////////////////////////////////////////////////
// protocol functions
function ProtoBroadcastAck(const szModule:PAnsiChar; hContact:TMCONTACT; type_:int; result_:int; hProcess:THANDLE; lParam:LPARAM): int_ptr; stdcall;
external AppDLL name 'ProtoBroadcastAck';
function ProtoServiceExists(const szModule, szName:PAnsiChar):int; stdcall;
external AppDLL name 'ProtoServiceExists';
procedure ProtoWindowAdd(pThis:pointer; wnd:HWND); stdcall;
external AppDLL name 'ProtoWindowAdd';
procedure ProtoWindowRemove(pThis:pointer; wnd:HWND); stdcall;
external AppDLL name 'ProtoWindowRemove';
// Call it in the very beginning of your proto's constructor
procedure ProtoConstructor(pThis:pointer{PPROTO_INTERFACE}; const pszModuleName:PAnsiChar; ptszUserName:PWideChar); stdcall;
external AppDLL name 'ProtoConstructor';
// Call it in the very end of your proto's destructor
procedure ProtoDestructor(pThis:pointer{PPROTO_INTERFACE}); stdcall;
external AppDLL name 'ProtoDestructor';
procedure ProtoLogA(pThis:pointer{PPROTO_INTERFACE}; szFormat :PAnsiChar; args:va_list); stdcall;
external AppDLL name 'ProtoLogA';
procedure ProtoLogW(pThis:pointer{PPROTO_INTERFACE}; wszFormat:PWideChar; args:va_list); stdcall;
external AppDLL name 'ProtoLogW';
// returns image extension by a PA_* constant or empty string for PA_FORMAT_UNKNOWN
function ProtoGetAvatarExtension(format:int):PWideChar; stdcall;
external AppDLL name 'ProtoGetAvatarExtension';
// detects image format by extension
function ProtoGetAvatarFormat(const szFileName:PWideChar):int; stdcall;
external AppDLL name 'ProtoGetAvatarFormat';
// detects image format by its contents
function ProtoGetAvatarFileFormat(const szFileName:PWideChar):int; stdcall;
external AppDLL name 'ProtoGetAvatarFileFormat';
// returns the image format and extension by the first bytes of picture
// ptszExtension might be NULL
function ProtoGetBufferFormat(const buf:PByte; var ext:PWideChar):int; stdcall;
external AppDLL name 'ProtoGetBufferFormat';
///////////////////////////////////////////////////////////////////////////////
// sha1 functions
const
MIR_SHA1_HASH_SIZE = 20;
type
pmir_sha1_ctx = ^mir_sha1_ctx;
mir_sha1_ctx = record
H:array [0.. 4] of longword;
W:array [0..79] of longword;
lenW:int;
sizeHi,sizeLo:longword;
end;
SHA1Hash = array [0..MIR_SHA1_HASH_SIZE-1] of byte;
procedure mir_sha1_init(ctx:pmir_sha1_ctx); stdcall;
external CoreDLL name 'mir_sha1_init';
procedure mir_sha1_append(ctx:pmir_sha1_ctx; dataIn:pbyte; len:int); stdcall;
external CoreDLL name 'mir_sha1_append';
procedure mir_sha1_finish(ctx:pmir_sha1_ctx; hashout:SHA1Hash); stdcall;
external CoreDLL name 'mir_sha1_finish';
procedure mir_sha1_hash(dataIn:pbyte; len:int;hashout:SHA1Hash); stdcall;
external CoreDLL name 'mir_sha1_hash';
procedure mir_hmac_sha1(hashout:SHA1Hash; const key:pbyte; keyLen:size_t;
const dataIn:pbyte; dataLen:size_t); stdcall;
external CoreDLL name 'mir_hmac_sha1';
///////////////////////////////////////////////////////////////////////////////
// strings
function mir_base64_decode(str:PAnsiChar; var resultSize:int):PByte; stdcall;
external CoreDLL name 'mir_base64_decode';
function mir_base64_encode(str:PByte; dataSize:int):PAnsiChar; stdcall;
external CoreDLL name 'mir_base64_encode';
function mir_base64_encodebuf(data:PByte; dataSize:int; output:PAnsiChar; outputLen:int):PAnsiChar; stdcall;
external CoreDLL name 'mir_base64_encodebuf';
function rtrim(str:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'rtrim';
function rtrimw(str:PWideChar):PWideChar; stdcall;
external CoreDLL name 'rtrimw';
// returns pointer to the beginning of string
function ltrim(str:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'ltrim';
function ltrimw(str:PWideChar):PWideChar; stdcall;
external CoreDLL name 'ltrimw';
// returns pointer to the trimmed portion of string
function ltrimp(str:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'ltrimp';
function ltrimpw(str:PWideChar):PWideChar; stdcall;
external CoreDLL name 'ltrimpw';
function wildcmp(name:PAnsiChar; mask:PAnsiChar):int; stdcall;
external CoreDLL name 'wildcmp';
function wildcmpw(name:PWideChar; mask:PWideChar):int; stdcall;
external CoreDLL name 'wildcmpw';
function wildcmpi(name:PAnsiChar; mask:PAnsiChar):int; stdcall;
external CoreDLL name 'wildcmpi';
function wildcmpiw(name:PWideChar; mask:PWideChar):int; stdcall;
external CoreDLL name 'wildcmpiw';
// mir_free dest, mir_strdup src to dest
function replaceStr(var dest:PAnsiChar; const src:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'replaceStr';
function replaceStrW(var dest:PWideChar; const src:PWideChar):PWideChar; stdcall;
external CoreDLL name 'replaceStrW';
function bin2hex(data:pointer; dataLen:size_t; pDest:PAnsiChar):PAnsiChar; stdcall;
external CoreDLL name 'bin2hex';
function bin2hexW(data:pointer; dataLen:size_t; pDest:PWideChar):PWideChar; stdcall;
external CoreDLL name 'bin2hexW';
///////////////////////////////////////////////////////////////////////////////
// text conversion functions
function mir_a2u_cp(src:PAnsiChar;codepage:int):PWideChar; stdcall;
external CoreDLL name 'mir_a2u_cp';
function mir_a2u(src:PAnsiChar):PWideChar; stdcall;
external CoreDLL name 'mir_a2u';
function mir_u2a_cp(src:PWideChar;codepage:int):PAnsiChar; stdcall;
external CoreDLL name 'mir_u2a_cp';
function mir_u2a(src:PWideChar):PAnsiChar; stdcall;
external CoreDLL name 'mir_u2a';
///////////////////////////////////////////////////////////////////////////////
// threads
type
pThreadFunc = procedure(ptr:pointer); cdecl;
pThreadFuncEx = function (ptr:pointer):uint_ptr; stdcall;
pThreadFuncOwner = function (owner:pointer;param:pointer):uint_ptr; cdecl;
function Thread_Push(hInst:HINST; Owner:pointer):int_ptr; stdcall;
external CoreDLL name 'Thread_Push';
function Thread_Pop():int_ptr; stdcall;
external CoreDLL name 'Thread_Pop';
procedure Thread_Wait(); stdcall;
external CoreDLL name 'Thread_Wait';
function forkthread(func:pThreadFunc; stacksize:uint; arg:pointer):uint_ptr; stdcall;
external CoreDLL name 'forkthread';
function forkthreadex(sec:pointer; stacksize:uint; func:pThreadFuncEx; owner:pointer; arg:pointer; thraddr:puint_ptr):uint_ptr; stdcall;
external CoreDLL name 'forkthreadex';
procedure Thread_SetName(const szThreadName:PAnsiChar); stdcall;
external CoreDLL name 'Thread_SetName';
procedure KillObjectThreads(pObject:pointer); stdcall;
external CoreDLL name 'KillObjectThreads';
///////////////////////////////////////////////////////////////////////////////
// utf8 interface
{ commented to avoid newer Delphi version conflicts
function Utf8Decode(str:PAnsiChar; var ucs2:PWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8Decode';
function Utf8DecodeCP(str:PAnsiChar; codepage:int; var ucs2:PWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8DecodeCP';
function Utf8DecodeW(const str:PAnsiChar):PWideChar;stdcall;
external CoreDLL name 'Utf8DecodeW';
function Utf8Encode(const src:PAnsiChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8Encode';
function Utf8EncodeCP(const src:PAnsiChar;codepage:int):PAnsiChar;stdcall;
external CoreDLL name 'Utf8EncodeCP';
function Utf8EncodeW(const src:PWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8EncodeW';
function Ucs2toUtf8Len(const src:PWideChar):int; stdcall;
external CoreDLL name 'Ucs2toUtf8Len';
function Utf8CheckString(const astr:PAnsiChar):bool;stdcall;
external CoreDLL name 'Utf8CheckString';
}
// aliases
function mir_utf8decode(str:PAnsiChar; var ucs2:PWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8Decode';
function mir_utf8decodecp(str:PAnsiChar; codepage:int; var ucs2:PWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8DecodeCP';
function mir_utf8decodew(const str:PAnsiChar):PWideChar;stdcall;
external CoreDLL name 'Utf8DecodeW';
function mir_utf8encode(const src:PAnsiChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8Encode';
function mir_utf8encodecp(const src:PAnsiChar;codepage:int):PAnsiChar;stdcall;
external CoreDLL name 'Utf8EncodeCP';
function mir_utf8encodew(const src:PWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8EncodeW';
function mir_utf8lenW(const src:PWideChar):int; stdcall;
external CoreDLL name 'Ucs2toUtf8Len';
function mir_utf8checkstring(const astr:PAnsiChar):bool;stdcall;
external CoreDLL name 'Utf8CheckString';
///////////////////////////////////////////////////////////////////////////////
// Window subclassing
procedure mir_subclassWindow(Wnd:HWND; WndProc:TWNDPROC); stdcall;
external CoreDLL name 'mir_subclassWindow';
procedure mir_subclassWindowFull(Wnd:HWND; WndProc, OldWndProc:TWNDPROC); stdcall;
external CoreDLL name 'mir_subclassWindowFull';
function mir_callNextSubclass(Wnd:HWND; WndProc:TWNDPROC; uMsg:uint; wParam:WPARAM; lParam:LPARAM ):LRESULT; stdcall;
external CoreDLL name 'mir_callNextSubclass';
procedure mir_unsubclassWindow(Wnd:HWND; WndProc:TWNDPROC); stdcall;
external CoreDLL name 'mir_unsubclassWindow';
procedure KillModuleSubclassing(hInst: HMODULE);
external CoreDLL name 'KillModuleSubclassing';
///////////////////////////////////////////////////////////////////////////////
// Windows utilities
function IsWinVerVistaPlus():bool; stdcall;
external CoreDLL name 'IsWinVerVistaPlus';
function IsWinVer7Plus():bool; stdcall;
external CoreDLL name 'IsWinVer7Plus';
function IsFullScreen():int; stdcall;
external CoreDLL name 'IsFullScreen';
function IsWorkstationLocked():int; stdcall;
external CoreDLL name 'IsWorkstationLocked';
function IsScreenSaverRunning():int; stdcall;
external CoreDLL name 'IsScreenSaverRunning';
procedure UnloadCoreModule(); stdcall;
external CoreDLL name 'UnloadCoreModule';
{$ENDIF}
|