mirror of
https://github.com/reactos/reactos.git
synced 2025-06-03 00:10:39 +00:00
[DLLEXPORT_TEST]
Add a test that checks the ability to link to function and data exports with cdecl, stdcall and c++ mangled names, including forwarders. It just prints "done". Feel free to convert it into a proper rostests, if you think it's required. svn path=/trunk/; revision=62269
This commit is contained in:
parent
fe029c9c69
commit
86d2e8f543
7 changed files with 283 additions and 0 deletions
|
@ -2,3 +2,4 @@ add_subdirectory(mmixer_test)
|
|||
if (NOT MSVC)
|
||||
add_subdirectory(pseh2)
|
||||
endif()
|
||||
add_subdirectory(dllexport)
|
||||
|
|
21
rostests/tests/dllexport/CMakeLists.txt
Normal file
21
rostests/tests/dllexport/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
spec2def(dllexport_test_dll1.dll dllexport_test_dll1.spec ADD_IMPORTLIB)
|
||||
spec2def(dllexport_test_dll2.dll dllexport_test_dll2.spec ADD_IMPORTLIB)
|
||||
|
||||
add_library(dllexport_test_dll1 SHARED
|
||||
dllexport_test_dll1.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dllexport_test_dll1.def)
|
||||
set_module_type(dllexport_test_dll1 win32dll ENTRYPOINT 0)
|
||||
add_importlibs(dllexport_test_dll1 dllexport_test_dll2)
|
||||
|
||||
add_library(dllexport_test_dll2 SHARED
|
||||
dllexport_test_dll2.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dllexport_test_dll2.def)
|
||||
set_module_type(dllexport_test_dll2 win32dll ENTRYPOINT 0)
|
||||
|
||||
|
||||
add_executable(dllexport_test
|
||||
dllexport_test.c)
|
||||
|
||||
set_module_type(dllexport_test win32cui)
|
||||
add_importlibs(dllexport_test dllexport_test_dll1 msvcrt kernel32 ntdll)
|
89
rostests/tests/dllexport/dllexport_test.c
Normal file
89
rostests/tests/dllexport/dllexport_test.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#endif
|
||||
|
||||
__declspec(dllimport) int __cdecl CdeclFunc0(void);
|
||||
__declspec(dllimport) int __cdecl CdeclFunc1(char* a1);
|
||||
__declspec(dllimport) int __cdecl CdeclFunc2(char* a1);
|
||||
__declspec(dllimport) int __cdecl CdeclFunc3(char* a1);
|
||||
|
||||
__declspec(dllimport) int __stdcall StdcallFunc0(void);
|
||||
__declspec(dllimport) int __stdcall StdcallFunc1(char* a1);
|
||||
__declspec(dllimport) int __stdcall StdcallFunc2(char* a1);
|
||||
__declspec(dllimport) int __stdcall StdcallFunc3(char* a1);
|
||||
__declspec(dllimport) int __stdcall StdcallFunc4(char* a1);
|
||||
__declspec(dllimport) int __stdcall StdcallFunc5(char* a1);
|
||||
|
||||
__declspec(dllimport) int __stdcall DecoratedStdcallFunc1(char* a1);
|
||||
__declspec(dllimport) int __stdcall DecoratedStdcallFunc2(char* a1);
|
||||
__declspec(dllimport) int __stdcall DecoratedStdcallFunc3(char* a1);
|
||||
__declspec(dllimport) int __stdcall DecoratedStdcallFunc4(char* a1);
|
||||
__declspec(dllimport) int __stdcall DecoratedStdcallFunc5(char* a1);
|
||||
|
||||
__declspec(dllimport) int __fastcall FastcallFunc0(void);
|
||||
__declspec(dllimport) int __fastcall FastcallFunc1(char* a1);
|
||||
__declspec(dllimport) int __fastcall FastcallFunc2(char* a1);
|
||||
__declspec(dllimport) int __fastcall FastcallFunc3(char* a1);
|
||||
__declspec(dllimport) int __fastcall FastcallFunc4(char* a1);
|
||||
__declspec(dllimport) int __fastcall FastcallFunc5(char* a1);
|
||||
|
||||
__declspec(dllimport) int __fastcall DecoratedFastcallFunc1(char* a1);
|
||||
__declspec(dllimport) int __fastcall DecoratedFastcallFunc2(char* a1);
|
||||
__declspec(dllimport) int __fastcall DecoratedFastcallFunc3(char* a1);
|
||||
__declspec(dllimport) int __fastcall DecoratedFastcallFunc4(char* a1);
|
||||
__declspec(dllimport) int __fastcall DecoratedFastcallFunc5(char* a1);
|
||||
|
||||
__declspec(dllimport) extern int DataItem1;
|
||||
__declspec(dllimport) extern int DataItem2;
|
||||
__declspec(dllimport) extern int DataItem3;
|
||||
|
||||
#define ok_int(a, b) \
|
||||
if ((a) != (b)) { printf("wrong result in line %d, expected 0x%x, got 0x%x\n", __LINE__, (b), (a)); }
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char* str = "defaultstring";
|
||||
|
||||
if (argc > 2)
|
||||
str = argv[1];
|
||||
|
||||
ok_int(CdeclFunc0(), 0);
|
||||
ok_int(CdeclFunc1(str), 1);
|
||||
ok_int(CdeclFunc2(str), 1);
|
||||
ok_int(CdeclFunc3(str), 0x10001);
|
||||
|
||||
ok_int(StdcallFunc0(), 0x10);
|
||||
ok_int(StdcallFunc1(str), 0x11);
|
||||
ok_int(StdcallFunc2(str), 0x11);
|
||||
ok_int(StdcallFunc3(str), 0x10011);
|
||||
ok_int(StdcallFunc4(str), 0x21);
|
||||
ok_int(StdcallFunc5(str), 0x10021);
|
||||
|
||||
ok_int(DecoratedStdcallFunc1(str), 0x21);
|
||||
ok_int(DecoratedStdcallFunc2(str), 0x11);
|
||||
//ok_int(DecoratedStdcallFunc3(str), 11);
|
||||
ok_int(DecoratedStdcallFunc4(str), 0x21);
|
||||
ok_int(DecoratedStdcallFunc5(str), 0x10021);
|
||||
|
||||
ok_int(FastcallFunc0(), 0x30);
|
||||
ok_int(FastcallFunc1(str), 0x31);
|
||||
ok_int(FastcallFunc2(str), 0x31);
|
||||
ok_int(FastcallFunc3(str), 0x10031);
|
||||
ok_int(FastcallFunc4(str), 0x42);
|
||||
ok_int(FastcallFunc5(str), 0x10041);
|
||||
ok_int(DecoratedFastcallFunc1(str), 0x42);
|
||||
ok_int(DecoratedFastcallFunc2(str), 0x31);
|
||||
//ok_int(DecoratedFastcallFunc3(str), 11);
|
||||
ok_int(DecoratedFastcallFunc4(str), 0x42);
|
||||
ok_int(DecoratedFastcallFunc5(str), 0x10041);
|
||||
|
||||
ok_int(DataItem1, 0x51);
|
||||
ok_int(DataItem2, 0x51);
|
||||
ok_int(DataItem3, 0x10051);
|
||||
|
||||
printf("done.\n");
|
||||
|
||||
return 0;
|
||||
}
|
49
rostests/tests/dllexport/dllexport_test_dll1.c
Normal file
49
rostests/tests/dllexport/dllexport_test_dll1.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
int __cdecl CdeclFunc0(void)
|
||||
{
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
int __cdecl CdeclFunc1(char *p1)
|
||||
{
|
||||
return 0x1;
|
||||
}
|
||||
|
||||
int __stdcall StdcallFunc0(void)
|
||||
{
|
||||
return 0x10;
|
||||
}
|
||||
|
||||
int __stdcall StdcallFunc1(char *p1)
|
||||
{
|
||||
return 0x11;
|
||||
}
|
||||
|
||||
int __stdcall DecoratedStdcallFunc1(char *p1)
|
||||
{
|
||||
return 0x21;
|
||||
}
|
||||
|
||||
int __fastcall FastcallFunc0(void)
|
||||
{
|
||||
return 0x30;
|
||||
}
|
||||
|
||||
int __fastcall FastcallFunc1(char *p1)
|
||||
{
|
||||
return 0x31;
|
||||
}
|
||||
|
||||
int __fastcall DecoratedFastcallFunc1(char *p1)
|
||||
{
|
||||
return 0x42;
|
||||
}
|
||||
|
||||
int __stdcall ExportByOrdinal1(char *p1)
|
||||
{
|
||||
return 0x11;
|
||||
}
|
||||
|
||||
int DataItem1 = 0x51;
|
||||
int DataItem2 = 0x52;
|
||||
|
55
rostests/tests/dllexport/dllexport_test_dll1.spec
Normal file
55
rostests/tests/dllexport/dllexport_test_dll1.spec
Normal file
|
@ -0,0 +1,55 @@
|
|||
|
||||
# Normal export of a cdecl function
|
||||
@ cdecl CdeclFunc0()
|
||||
@ cdecl CdeclFunc1(ptr)
|
||||
|
||||
# Redirected cdecl function
|
||||
@ cdecl CdeclFunc2() CdeclFunc1
|
||||
@ cdecl CdeclFunc3() dllexport_test_dll2.CdeclFunc1
|
||||
|
||||
# Normal export of a stdcall function
|
||||
@ stdcall StdcallFunc0()
|
||||
@ stdcall StdcallFunc1(ptr)
|
||||
|
||||
# Decorated export of a stdcall function
|
||||
@ stdcall _StdcallFunc1@4(ptr)
|
||||
@ stdcall _DecoratedStdcallFunc1@4(ptr)
|
||||
|
||||
# Redirected stdcall function
|
||||
@ stdcall StdcallFunc2(ptr) StdcallFunc1
|
||||
@ stdcall StdcallFunc3(ptr) dllexport_test_dll2.StdcallFunc1
|
||||
@ stdcall StdcallFunc4(ptr) _DecoratedStdcallFunc1@4
|
||||
@ stdcall StdcallFunc5(ptr) dllexport_test_dll2._DecoratedStdcallFunc1@4
|
||||
@ stdcall _DecoratedStdcallFunc2@4(ptr) StdcallFunc1
|
||||
; @ stdcall _DecoratedStdcallFunc3@4(ptr) dllexport_test_dll2.StdcallFunc1 # This doesn't work with MSVC!
|
||||
@ stdcall _DecoratedStdcallFunc4@4(ptr) _DecoratedStdcallFunc1@4
|
||||
@ stdcall _DecoratedStdcallFunc5@4(ptr) dllexport_test_dll2._DecoratedStdcallFunc1@4
|
||||
|
||||
# Normal export of a fastcall function
|
||||
@ fastcall FastcallFunc0()
|
||||
@ fastcall FastcallFunc1(ptr)
|
||||
|
||||
# Decorated export of a fastcall function
|
||||
@ fastcall @DecoratedFastcallFunc1@4(ptr)
|
||||
|
||||
# Redirected fastcall function
|
||||
@ fastcall FastcallFunc2(ptr) FastcallFunc1
|
||||
@ fastcall FastcallFunc3(ptr) dllexport_test_dll2.FastcallFunc1
|
||||
@ fastcall FastcallFunc4(ptr) @DecoratedFastcallFunc1@4
|
||||
@ fastcall FastcallFunc5(ptr) dllexport_test_dll2.@DecoratedFastcallFunc1@4
|
||||
|
||||
@ fastcall @DecoratedFastcallFunc2@4(ptr) FastcallFunc1
|
||||
; @ fastcall @DecoratedFastcallFunc3@4(ptr) dllexport_test_dll2.FastcallFunc1 # This doesn't work with MSVC!
|
||||
@ fastcall @DecoratedFastcallFunc4@4(ptr) @DecoratedFastcallFunc1@4
|
||||
@ fastcall @DecoratedFastcallFunc5@4(ptr) dllexport_test_dll2.@DecoratedFastcallFunc1@4
|
||||
|
||||
# Normal export of data
|
||||
@ extern DataItem1
|
||||
|
||||
# Redirected data
|
||||
@ extern DataItem2 DataItem1
|
||||
@ extern DataItem3 dllexport_test_dll2.DataItem1
|
||||
|
||||
# other stuff
|
||||
123 stdcall @(ptr) ExportByOrdinal1
|
||||
218 stdcall -noname ExportByOrdinal1(ptr)
|
45
rostests/tests/dllexport/dllexport_test_dll2.c
Normal file
45
rostests/tests/dllexport/dllexport_test_dll2.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
|
||||
int __cdecl CdeclFunc0(void)
|
||||
{
|
||||
return 0x10000;
|
||||
}
|
||||
|
||||
int __cdecl CdeclFunc1(char *p1)
|
||||
{
|
||||
return 0x10001;
|
||||
}
|
||||
|
||||
int __stdcall StdcallFunc0(void)
|
||||
{
|
||||
return 0x10010;
|
||||
}
|
||||
|
||||
int __stdcall StdcallFunc1(char *p1)
|
||||
{
|
||||
return 0x10011;
|
||||
}
|
||||
|
||||
int __stdcall DecoratedStdcallFunc1(char *p1)
|
||||
{
|
||||
return 0x10021;
|
||||
}
|
||||
|
||||
int __fastcall FastcallFunc0(void)
|
||||
{
|
||||
return 0x10030;
|
||||
}
|
||||
|
||||
int __fastcall FastcallFunc1(char *p1)
|
||||
{
|
||||
return 0x10031;
|
||||
}
|
||||
|
||||
int __fastcall DecoratedFastcallFunc1(char *p1)
|
||||
{
|
||||
return 0x10041;
|
||||
}
|
||||
|
||||
int DataItem1 = 0x10051;
|
||||
int DataItem2 = 0x10052;
|
||||
|
||||
|
23
rostests/tests/dllexport/dllexport_test_dll2.spec
Normal file
23
rostests/tests/dllexport/dllexport_test_dll2.spec
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
# Normal export of a cdecl function
|
||||
@ cdecl CdeclFunc0()
|
||||
@ cdecl CdeclFunc1(ptr)
|
||||
|
||||
# Normal export of a stdcall function
|
||||
@ stdcall StdcallFunc0()
|
||||
@ stdcall StdcallFunc1(ptr)
|
||||
|
||||
# Decorated export of a stdcall function
|
||||
@ stdcall _DecoratedStdcallFunc1@4(ptr)
|
||||
|
||||
# Normal export of a fastcall function
|
||||
@ fastcall FastcallFunc0()
|
||||
@ fastcall FastcallFunc1(ptr)
|
||||
|
||||
# Decorated export of a fastcall function
|
||||
@ fastcall @DecoratedFastcallFunc1@4(ptr)
|
||||
|
||||
# Normal export of data
|
||||
@ extern DataItem1
|
||||
@ extern DataItem2
|
||||
|
Loading…
Reference in a new issue