|
From: | Christian Jullien |
Subject: | [Tinycc-devel] A Windows tool is missing |
Date: | Mon, 27 Jan 2020 15:42:37 +0100 |
When tcc is used on Windows we miss mt.exe (Manifest Tool) which sets a manifest in an executable in order to add different operating system level supports. For example, a manifest looks lile: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <description>OpenLisp by Eligis</description> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Supports Windows Vista functionality --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <!-- Supports Windows 7 functionality --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!-- Supports Windows 8 functionality --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <!-- Supports Windows 8.1 functionality --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <!-- Supports Windows 10 functionality --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> </application> </compatibility> <!-- Identify the application security requirements. --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false" /> </requestedPrivileges> </security> </trustInfo> </assembly> I would like to include a simplified version somewhere in win32 I just wrote and works as mt.exe drop down replacement (i.e. same interface at least to put a manifest). It may become a tcc interface “tcc –mt” similar to “tcc –ar” we already have. Any hint where I can put this file? win32/src/ ? Needless to say it compiles with tcc.exe /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the TinyCC package. * No warranty is given; refer to the file DISCLAIMER within this package. */ #define WIN32_LEAN_AND_MEAN #include <stdio.h> #include <string.h> #include <stdlib.h> #include <windows.h> static const char* help = "Usage:\n" "-----\n" "tcc-mt\n" " [ -manifest <manifest1 name> <manifest2 name> ... ]\n" " [ -outputresource:<file> ]\n" " [ -nologo ]\n"; int main(int argc, char** argv) { int i = 1; long len; int nologo = 0; char* manifest = NULL; char *out = NULL; HANDLE handle; while (argv[i] != NULL && argv[i][0] == '-') { if (strcmp(argv[i], "-nologo") == 0) { nologo = 1; ++i; } else if (strcmp(argv[i], "-manifest") == 0) { if (argv[++i] != NULL) { FILE *fd = fopen(argv[i], "rb"); if (fd == NULL) { perror("Can't open manifest"); return 1; } (void)fseek(fd, 0, SEEK_END); len = ftell(fd); (void)rewind(fd); manifest = malloc(len); if (fread(manifest, len, 1, fd) != 1) { perror("manifest read error"); return 1; } fclose(fd); ++i; } } else if (strncmp(argv[i], "-outputresource:", 16) == 0) { out = &argv[i][16]; ++i; } else { (void)fprintf(stderr, "%s: unsupported option '%s'\n", argv[i]); (void)fprintf(stderr, help); return 1; } } if (nologo == 0) { (void)printf("Tiny C Simplified Manifest Tool\n"); } if (out == NULL) { (void)fprintf(stderr, "-outputresource: is a required option.\n"); (void)fprintf(stderr, help); } if (manifest == NULL) { (void)fprintf(stderr, "-manifest is a required option.\n"); (void)fprintf(stderr, help); } handle = BeginUpdateResource(out, TRUE); UpdateResource(handle, RT_MANIFEST, CREATEPROCESS_MANIFEST_RESOURCE_ID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPVOID)manifest, (DWORD)len); EndUpdateResource(handle, FALSE); free(manifest); } |
[Prev in Thread] | Current Thread | [Next in Thread] |