Hello,
The attachment contains the 32-bit and 64-bit versions of the import library for Universal C Runtime. The libraries are created from the text file listing the functions exported by UCRT.
A quick example :
#include <stdio.h>
#include <stdarg.h>
extern FILE* __cdecl __acrt_iob_func(unsigned Index);
#define _stdin (__acrt_iob_func(0))
#define _stdout (__acrt_iob_func(1))
#define _stderr (__acrt_iob_func(2))
char *_strupr(char *str);
unsigned long _getdrives( void );
int __cdecl __stdio_common_vfprintf(unsigned __int64 _Options, FILE* _Stream, char const* _Format , int _Locale, va_list);
int printf(const char * format, ...)
{
int retVal;
va_list vl;
va_start(vl, format);
retVal = __stdio_common_vfprintf(0, _stdout,format, 0, vl);
va_end(vl);
return retVal;
}
int main(int argc,char *argv[])
{
char szDrvMsg[] = "A:\n";
char mystr[]="This is a string printed with UCRT printf.\n";
unsigned long uDriveMask;
printf("%s\n",_strupr(mystr));
printf("Detected logical drives:\n");
uDriveMask = _getdrives();
while (uDriveMask) {
if (uDriveMask & 1)
printf(szDrvMsg);
++szDrvMsg[0];
uDriveMask >>= 1;
}
return 0;
}
Determining the functions imported by the example code :
\PellesC\bin\podump.exe /IMPORTS Hello32.exe
Dump of Hello32.exe
File type: EXE
Imported symbols
api-ms-win-crt-stdio-l1-1-0.dll
0 time date stamp (Thu Jan 1 03:00:00 1970)
hint name
0 __acrt_iob_func
3 __stdio_common_vfprintf
api-ms-win-crt-string-l1-1-0.dll
0 time date stamp (Thu Jan 1 03:00:00 1970)
hint name
3D _strupr
api-ms-win-crt-filesystem-l1-1-0.dll
0 time date stamp (Thu Jan 1 03:00:00 1970)
hint name
15 _getdrives
KERNEL32.dll
0 time date stamp (Thu Jan 1 03:00:00 1970)
hint name
0 GetCommandLineA
0 ExitProcess
Thanks for sharing!
I may be dense, but what is the benefit over using Pelles C functions directly?
Hi Akko,
Pelle's C run-rime library is very good. If one day MS is deciding to remove the traditional msvcrt.dll, the replacement will be the new Universal C Runtime. My library is just an attempt to be prepared for tomorrow.
If someone want to compare different functions, how those works other than Pelles C crt, how someone do that without different compiler system ?
msvcrt.dll and ucrtbase.dll + others are Windows OS dlls, that will be mostly in every Windows OSes
Also a linker's map-file is easier to read.
Also poasm users needs simple way to print out variables, while testing and sharing code examples.
Hello,
The MS tools to build the import libraries can be obtained from here :
https://github.com/Data-Oriented-House/PortableBuildTools
Is it possible to build that ucrt.lib with polib.exe too ?
Hi Timo,
I will try it with the latest release of Polink.
Hi Timo,
Here is my report. Run the two MakeLibs.bat files to create the import libraries for both of the 32-bit and 64-bit architectures :
set p=E:\PellesC\bin
.
.
%p%\Polib.exe /MACHINE:x86 /OUT:ucrt.lib api-ms-win-crt-conio-l1-1-0.lib api-ms-win-crt-convert-l1-1-0.lib api-ms-win-crt-environment-l1-1-0.lib api-ms-win-crt-filesystem-l1-1-0.lib api-ms-win-crt-heap-l1-1-0.lib api-ms-win-crt-locale-l1-1-0.lib api-ms-win-crt-math-l1-1-0.lib api-ms-win-crt-multibyte-l1-1-0.lib api-ms-win-crt-process-l1-1-0.lib api-ms-win-crt-runtime-l1-1-0.lib api-ms-win-crt-stdio-l1-1-0.lib api-ms-win-crt-string-l1-1-0.lib api-ms-win-crt-time-l1-1-0.lib api-ms-win-crt-utility-l1-1-0.lib
Polib reports some warning messages bot they are not harmful :
POLIB: warning: No symbols added from 'api-ms-win-crt-convert-l1-1-0.dll'; thismember will never be seen by the linker.
POLIB: warning: No symbols added from 'api-ms-win-crt-environment-l1-1-0.dll'; this member will never be seen by the linker.
POLIB: warning: No symbols added from 'api-ms-win-crt-filesystem-l1-1-0.dll'; this member will never be seen by the linker.
POLIB: warning: No symbols added from 'api-ms-win-crt-heap-l1-1-0.dll'; this member will never be seen by the linker.
.
.
.
POLIB: warning: No symbols added from 'api-ms-win-crt-string-l1-1-0.dll'; this member will never be seen by the linker.
POLIB: warning: No symbols added from 'api-ms-win-crt-time-l1-1-0.dll'; this member will never be seen by the linker.
POLIB: warning: No symbols added from 'api-ms-win-crt-utility-l1-1-0.dll'; thismember will never be seen by the linker.
Simple example built with Pelles C :
\PellesC\bin\podump.exe /IMPORTS Test.exe
Dump of Test.exe
File type: EXE
Imported symbols
api-ms-win-crt-stdio-l1-1-0.dll
406128 import address table
406064 import name table
0 time date stamp (Thu Jan 1 03:00:00 1970)
0 index of first forwarder reference
hint name
0 __acrt_iob_func
0 __stdio_common_vfprintf
api-ms-win-crt-string-l1-1-0.dll
406134 import address table
406070 import name table
0 time date stamp (Thu Jan 1 03:00:00 1970)
0 index of first forwarder reference
hint name
0 _strupr
api-ms-win-crt-filesystem-l1-1-0.dll
40613C import address table
406078 import name table
0 time date stamp (Thu Jan 1 03:00:00 1970)
0 index of first forwarder reference
hint name
0 _getdrives
Nice, no need additional MS tools
EDIT:
If someone don't need Pelles C crt and don't need commanline
#pragma nodefaultlib
void __cdecl mainCRTStartup(void)
{
void __cdecl exit(int status);
int __cdecl main(void);
exit(main());
}