- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
Latest commit
77 lines (71 loc) · 2.38 KB
/
Copy pathmain.cpp
File metadata and controls
77 lines (71 loc) · 2.38 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
#include<iostream>
#include<windows.h>
// part that normally should be in resource.h file
#defineIDR_RCDATA1300
#defineIDS_STRING11
#defineIDS_STRING22
#defineIDS_STRING33
// end of this part
// dynamic procedure type definition
typedefunsignedlong (CALLBACK *FPROC)(unsignedchar*);
// dynamic procedure definition
FPROCDLL_1;
unsignedcharCALLBACK __export Test(unsignedchar* test) {
return ((unsignedchar)DLL_1(test));
};
// end of dynamic procedure definition
intmain(void) {
unsignedchar test[5];
char test3[256];
HINSTANCE hLib=LoadLibrary("testlib2.dll");
if(hLib < 32) {
std::cout << "FAIL" << std::endl;
} else {
std::cout << "OK" << std::endl;
DLL_1=(FPROC)GetProcAddress(hLib,"Test");
if(DLL_1!=NULL) {
std::cout << "OK" << std::endl;
test[0]=3;
test[1]=4;
std::cout << (unsignedint)Test(test) << std::endl;
}
HGLOBAL hMem = LoadResource(hLib,FindResource(hLib,MAKEINTRESOURCE(IDR_RCDATA1),RT_RCDATA));
if(hMem==NULL) {
std::cout << "FAIL" << std::endl;
} else {
std::cout << "OK" << std::endl;
WORD *test2 = (WORD*)LockResource(hMem);
if(test2==NULL) {
std::cout << "FAIL" << std::endl;
} else {
std::cout << "OK" << std::endl;
unsignedint x=0;
while(test2[x]) {
test3[x]=(char)test2[x];
++x;
}
test3[x]=0;
std::cout << test3 << std::endl;
UnlockResource(hMem);
}
FreeResource(hMem);
}
if(LoadString(hLib,IDS_STRING1,test3,256)) {
std::cout << test3 << std::endl;
} else {
std::cout << "FAIL" << std::endl;
}
if(LoadString(hLib,IDS_STRING2,test3,256)) {
std::cout << test3 << std::endl;
} else {
std::cout << "FAIL" << std::endl;
}
if(LoadString(hLib,IDS_STRING3,test3,256)) {
std::cout << test3 << std::endl;
} else {
std::cout << "FAIL" << std::endl;
}
FreeLibrary(hLib);
}
return0;
}