I know that this sounds weird, but I don't wanna see a MSVCR120.dll in my program's IAT. This always sucks while running your program in new computer because they don't have this dll installed.
After some Googling I found #pragma intrinsic(memcpy)
seems be designed for my problem, but it actually NOT.
Here is a small code for demonstration:
#pragma intrinsic(memcpy)
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <windows.h>
void main(int argc,char **argv)
{
// simple cat implementation
if (argc>1)
{
FILE *f = fopen(argv[1], "rb");
fseek(f, 0, SEEK_END);
DWORD size = ftell(f);
fseek(f, 0, SEEK_SET);
char *buf = (char*)malloc(size);
fread_s(buf, size, 1, size, f);
// below is nonsense , but for demonstration
char *buf2 = new char[size+1];
memcpy(buf2, buf, size); // this memcpy is **NOT** inlined!
puts(buf2);
}
}
Yes, I do know there is a memcpy function implemented in ntdll and I can use it via GetProcAddress, but now I wanna test why #pragma intrinsic(memcpy)
does NOT work at all.
The code above will generate something likes this:
This memcpy is actually a wrapper for calling real memcpy function in msvcr120.dll.
And there is a memcpy in its IAT:
I'm pretty sure I have enabled the intrinsic function in my compiler's option:
Is there a solution for this? Thanks.
EDIT: I notice that there exist a msvcrt.dll in almost all version of windows. So is there a options that I can link msvcrt.dll instead of msvcr120.dll?