-
-
[原创]为无源码的DLL增加接口功能
-
发表于:
2023-1-9 22:15
10663
-
完整源代码:
using namespace std;
void __declspec(dllexport) CalculateFunc(
int
count)
{
int
index
=
0
;
for
(
int
i
=
0
; i < count; i
+
+
)
{
printf(
"i=%d, %d...\n"
, i,
+
+
index);
Sleep(
1000
);
}
printf(
"Threader Over...\n"
);
}
int
g_indexRef
=
0
;
void myThread(
int
count)
{
__asm
{
push eax
mov eax, esp
sub eax,
0x10
mov g_indexRef, eax
push count
call CalculateFunc
add esp,
4
pop eax
}
}
void CalculateFuncAsync()
{
std::thread thread(myThread,
100
);
thread.join();
/
/
等待线程结束
}
int
main()
{
std::thread thread(CalculateFuncAsync);
Sleep(
3000
);
if
(g_indexRef)
{
*
((
int
*
)g_indexRef)
=
100
;
thread.join();
}
printf(
"Main Over...\n"
);
return
0
;
}
using namespace std;
void __declspec(dllexport) CalculateFunc(
int
count)
{
int
index
=
0
;
for
(
int
i
=
0
; i < count; i
+
+
)
{
printf(
"i=%d, %d...\n"
, i,
+
+
index);
Sleep(
1000
);
}
printf(
"Threader Over...\n"
);
}
int
g_indexRef
=
0
;
void myThread(
int
count)
{
__asm
{
push eax
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
最后于 2023-1-9 22:26
被_THINCT编辑
,原因: