I am using this code here :
include "windows.h"
#include "stdio.h"
#include <conio.h>
#pragma comment(lib, "StubDLL.lib")
// StubDLL defines as __declspec(dllexport) Add and Function
#include "StubDLL.h"
// just to try it with MS Function
__declspec(dllimport) HANDLE WINAPI GetCurrentProcess(void);
/*
this is done in StubDLL.h
extern "C"
{
__declspec(dllimport) int Add(int a, int b);
__declspec(dllimport) void Function(void);
}
*/
int main()
{
Function();
std::cout << Add(32, 58) << "\n";
HANDLE test = GetCurrentProcess();
printf("%d \n", test);
return 0;
}
now, according to: https://msdn.microsoft.com/en-us/library/aa271769(v=vs.60).aspx:
__declspec(dllimport) hints the compiler backend that the function called resides in an external DLL and therefore should not generate an indirect call (FF 15 ...) meaning no indirect calls to a trampoline...
when looking at the disassembly, Function(), Add(), and GetCurrentProcess() result in indirect far calls, which should not happen, as I explicitly give the compiler the hint not to emit an "FF15" but insted an "E8".
Apparently I am missing sth. here... Any hints ? ( project setting is VS 2015, Release build, no incremantal linking, size over speed, optimize for size)