1 /* Windows-specific code for wimlib-imagex. */
4 # error "This file contains Windows code"
7 #include "imagex-win32.h"
13 /* Convert a string from the "current Windows codepage" to UTF-16LE. */
15 win32_mbs_to_wcs(const char *mbs, size_t mbs_nbytes, size_t *num_wchars_ret)
17 if (mbs_nbytes > INT_MAX) {
18 fwprintf(stderr, L"ERROR: too much data (%zu bytes)!\n",
22 if (mbs_nbytes == 0) {
26 int len = MultiByteToWideChar(CP_ACP,
34 wchar_t *wcs = malloc(len * sizeof(wchar_t));
36 fwprintf(stderr, L"ERROR: out of memory!\n");
39 int len2 = MultiByteToWideChar(CP_ACP,
49 *num_wchars_ret = len;
53 L"ERROR: Invalid multi-byte string in the text file you provided as input!\n"
54 L" Maybe try converting your text file to UTF-16LE?\n"
59 /* Set a file descriptor to binary mode. */
60 void set_fd_to_binary_mode(int fd)
62 _setmode(fd, _O_BINARY);
68 get_security_descriptor_string(PSECURITY_DESCRIPTOR desc)
71 /* 52 characters!!! */
72 ConvertSecurityDescriptorToStringSecurityDescriptorW(
75 OWNER_SECURITY_INFORMATION |
76 GROUP_SECURITY_INFORMATION |
77 DACL_SECURITY_INFORMATION |
78 SACL_SECURITY_INFORMATION,
85 win32_print_security_descriptor(const uint8_t *sd, size_t size)
88 const wchar_t *printstr;
90 /* 'size' is ignored here due to the crappy Windows APIs. Oh well, this
91 * is just for debugging anyway. */
92 str = get_security_descriptor_string((PSECURITY_DESCRIPTOR)sd);
96 printstr = L"(invalid)";
98 wprintf(L"Security Descriptor = %ls\n", printstr);