forked from PavelMinenkov/AIO
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBoost.pas
More file actions
78 lines (65 loc) · 1.83 KB
/
Boost.pas
File metadata and controls
78 lines (65 loc) · 1.83 KB
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
unit Boost;
interface
uses SysUtils;
const
BOOST_CONTEXT_LIBRARY =
{$IFDEF CPUX86}
{$IFDEF MSWINDOWS}
'boost_context_i386.dll'
{$ENDIF MSWINDOWS}
{$IFDEF LINUX}
'boost_context_i386.so'
{$ENDIF LINUX}
{$IFDEF IOS}
{$MESSAGE ERROR 'Unknown condition'}
{$ENDIF IOS}
{$ENDIF CPUX86}
{$IFDEF CPUX64}
{$IFDEF MSWINDOWS}
'boost_context_x64.dll'
{$ENDIF MSWINDOWS}
{$IFDEF LINUX}
'boost_context_x64.so'
{$ENDIF LINUX}
{$IFDEF IOS}
{$MESSAGE ERROR 'Unknown condition'}
{$ENDIF IOS}
{$ENDIF CPUX64};
type
// Running context
TContext = Pointer;
// Context entry point
TEnterProc = procedure(Param: Pointer); cdecl;
procedure jump_fcontext(var ofc: TContext; nfc: TContext;
param: Pointer; regs: Boolean);
function make_fcontext(StackPtr: Pointer; StackSize: NativeUInt;
EnterProc: TEnterProc): TContext;
implementation
uses Windows;
var
LibHandle: THandle;
jump_fcontext_func: procedure(var ofc: TContext; nfc: TContext;
param: Pointer; regs: Boolean); cdecl;
make_fcontext_func: function(StackPtr: Pointer; StackSize: NativeUInt;
EnterProc: TEnterProc): TContext; cdecl;
procedure jump_fcontext(var ofc: TContext; nfc: TContext; param: Pointer;
regs: Boolean);
begin
if LibHandle > 0 then
jump_fcontext_func(ofc, nfc, param,regs );
end;
function make_fcontext(StackPtr: Pointer; StackSize: NativeUInt;
EnterProc: TEnterProc): TContext;
begin
if LibHandle > 0 then
Result := make_fcontext_func(StackPtr, StackSize, EnterProc)
else
Result := nil;
end;
initialization
LibHandle := LoadLibrary(BOOST_CONTEXT_LIBRARY);
if LibHandle > 0 then begin
@jump_fcontext_func := GetProcAddress(LibHandle, 'jump_fcontext');
@make_fcontext_func := GetProcAddress(LibHandle, 'make_fcontext');
end
end.