#include #define ISOLATION_AWARE_ENABLED 1 #include __declspec(dllimport) int funca( int i ); int main( int argc, char **argv ) { char buf[ 100 ]; HMODULE hb = LoadLibrary( "dll\\b.dll" ); int (*b)(int) = GetProcAddress( hb, "funcb" ); printf( "hmodule: %x *funcb:%x \n", hb, b ); funca( 1 ); printf( "Back in main after calling locally bound funca\n"); gets( buf ); b( 2 ); return 0; } /* a.dll (v1)*/ #include __declspec(dllexport) int _stdcall funca( int i ) { return printf( "a.dll{v1.0.0.0}:funca() called with %d\n", i ); } /* b.dll */ #include __declspec(dllexport) int funcb( int i ) { printf( "b.dll:funcb() called with %d\n", i ); funca( i + 1 ); return 1; } /* a.dll (v2)*/ #include __declspec(dllexport) int funca( int i ) { return printf( "a.dll{v2.0.0.0}:funca() called with %d\n", i ); } #### #### #### @rem makeit.cmd del /S /Q *.obj *.lib *.dll *.exe cd dll cl /MT /LD a.c mt -manifest a.dll.manifest -outputresource:a.dll;#1 cl /MT /LD b.c a.lib /link /manifest "/manifestdependency:type='win32' name='a.dll' version='2.0.0.0'" mt -manifest b.dll.manifest -outputresource:b.dll;#1 cd .. cl /MT /LD a.c mt -manifest a.dll.manifest -outputresource:a.dll;#1 cl /MT main.c a.lib /link /manifest "/manifestdependency:type='win32' name='a.dll' version='1.0.0.0'" mt -manifest main.exe.manifest -outputresource:main.exe;#1 #### C:\test\manifest>makeit C:\test\manifest>del /S /Q *.obj *.lib *.dll *.exe Deleted file - C:\test\manifest\a.obj Deleted file - C:\test\manifest\main.obj Deleted file - C:\test\manifest\a.lib Deleted file - C:\test\manifest\a.dll Deleted file - C:\test\manifest\main.exe Deleted file - C:\test\manifest\dll\a.obj Deleted file - C:\test\manifest\dll\b.obj Deleted file - C:\test\manifest\dll\a.lib Deleted file - C:\test\manifest\dll\b.lib Deleted file - C:\test\manifest\dll\a.dll Deleted file - C:\test\manifest\dll\b.dll C:\test\manifest>cd dll C:\test\manifest\dll>cl /MT /LD a.c Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. a.c Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. /out:a.dll /dll /implib:a.lib a.obj Creating library a.lib and object a.exp C:\test\manifest\dll>mt -manifest a.dll.manifest -outputresource:a.dll;#1 Microsoft (R) Manifest Tool version 5.2.3790.2075 Copyright (c) Microsoft Corporation 2005. All rights reserved. C:\test\manifest\dll>cl /MT /LD b.c a.lib /link /manifest "/manifestdependency:type='win32' name='a.dll' version='2.0.0.0'" Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. b.c Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. /out:b.dll /dll /implib:b.lib /manifest "/manifestdependency:type='win32' name='a.dll' version='2.0.0.0'" b.obj a.lib Creating library b.lib and object b.exp C:\test\manifest\dll>mt -manifest b.dll.manifest -outputresource:b.dll;#1 Microsoft (R) Manifest Tool version 5.2.3790.2075 Copyright (c) Microsoft Corporation 2005. All rights reserved. C:\test\manifest\dll>cd .. C:\test\manifest>cl /MT /LD a.c Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. a.c Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. /out:a.dll /dll /implib:a.lib a.obj Creating library a.lib and object a.exp C:\test\manifest>mt -manifest a.dll.manifest -outputresource:a.dll;#1 Microsoft (R) Manifest Tool version 5.2.3790.2075 Copyright (c) Microsoft Corporation 2005. All rights reserved. C:\test\manifest>cl /MT main.c a.lib /link /manifest "/manifestdependency:type='win32' name='a.dll' version='1.0.0.0'" Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. main.c main.c(11) : warning C4113: 'FARPROC' differs in parameter lists from 'int (__cdecl *)(int)' main.c(11) : warning C4133: 'initializing' : incompatible types - from 'FARPROC' to 'int (__cdecl *)(int)' Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. /out:main.exe /manifest "/manifestdependency:type='win32' name='a.dll' version='1.0.0.0'" main.obj a.lib C:\test\manifest>mt -manifest main.exe.manifest -outputresource:main.exe;#1 Microsoft (R) Manifest Tool version 5.2.3790.2075 Copyright (c) Microsoft Corporation 2005. All rights reserved. #### C:\test\manifest>main hmodule: 640000 *funcb:641000 a.dll{v1.0.0.0}:funca() called with 1 Back in main after calling locally bound funca b.dll:funcb() called with 2 a.dll{v1.0.0.0}:funca() called with 3