20#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
24#if !defined(_MSC_VER) && !defined(__cdecl)
40#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
43#define min(a,b) (((a) < (b)) ? (a) : (b))
47#define strcasecmp _stricmp
53#define SW_SHOWNORMAL 1
54#define SW_SHOWMINNOACTIVE 7
71#define DEFINE_GUID2(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID name = { l,w1,w2,{ b1,b2,b3,b4,b5,b6,b7,b8 } }
72DEFINE_GUID2(CLSID_ShellLink, 0x00021401,0,0,0xC0,0,0,0,0,0,0,0x46);
73DEFINE_GUID2(CLSID_MyComputer,0x20D04FE0,0x3AEA,0x1069,0xA2,0xD8,0x08,0x00,0x2B,0x30,0x30,0x9D);
75#define LOCATOR_LOCAL 0x1
76#define LOCATOR_NETWORK 0x2
88#define SLDF_DEFAULT 0x00000000
89#define SLDF_HAS_ID_LIST 0x00000001
90#define SLDF_HAS_LINK_INFO 0x00000002
91#define SLDF_HAS_NAME 0x00000004
92#define SLDF_HAS_RELPATH 0x00000008
93#define SLDF_HAS_WORKINGDIR 0x00000010
94#define SLDF_HAS_ARGS 0x00000020
95#define SLDF_HAS_ICONLOCATION 0x00000040
96#define SLDF_UNICODE 0x00000080
97#define SLDF_HAS_EXP_SZ 0x00000200
98#define SLDF_HAS_EXP_ICON_SZ 0x00004000
100#define LINK_ID_LIST SLDF_HAS_ID_LIST
101#define LINK_FILE SLDF_HAS_LINK_INFO
102#define LINK_DESCRIPTION SLDF_HAS_NAME
103#define LINK_RELATIVE_PATH SLDF_HAS_RELPATH
104#define LINK_WORKING_DIR SLDF_HAS_WORKINGDIR
105#define LINK_CMDLINE_ARGS SLDF_HAS_ARGS
106#define LINK_ICON SLDF_HAS_ICONLOCATION
107#define LINK_UNICODE SLDF_UNICODE
153#define PT_DRIVE1 0x2F
154#define PT_FOLDER 0x31
158#define REGITEMORDER_DEFAULT 0x80
159#define REGITEMORDER_LIBRARIES 0x42
160#define REGITEMORDER_USERSFILEFOLDER 0x44
161#define REGITEMORDER_MYCOMPUTER 0x50
196#define EXP_SPECIAL_FOLDER_SIG 0xA0000005
207#define EXP_SZ_LINK_SIG 0xA0000001
208#define EXP_SZ_ICON_SIG 0xA0000007
225#define CSIDL_WINDOWS 0x24
226#define CSIDL_SYSTEM 0x25
235 {
CSIDL_SYSTEM,
"system",
"X:\\reactos\\system32",
"%SystemRoot%\\system32" },
268 wcstr[
i] = (
wchar_t)mbstr[
i];
272#define mbstowcs my_mbstowcs
288 return (
c ==
'\\' ||
c ==
'/');
315 if ((
ptr >
str + 1) && (*
str ==
'"') && (*(
ptr-1) ==
'"'))
324 if (*
ptr ==
'^' && *(
ptr+1) ==
'%')
340 buf[
sizeof(
"shell:") - 1] =
'\0';
344 target +=
sizeof(
"shell:") - 1;
345 for (
unsigned long i = 0;; ++
i)
378 wchar_t tmpBufferU[1024];
380 fwrite(tmpBufferU, uhTmp *
sizeof(
wchar_t), 1,
pFile);
386 const char *pszOutputPath =
"shortcut.lnk";
387 const char *pszTarget =
NULL;
388 const char *pszDescription =
NULL;
389 const char *pszWorkingDir =
NULL;
390 const char *pszCmdLineArgs =
NULL;
391 const char *pszIcon =
NULL;
395 bool bHelp =
false, bUnicode =
false, bMinimized =
false;
408 if ((
argv[
i][0] ==
'-' ||
argv[
i][0] ==
'/') &&
431 pszOutputPath =
argv[
i];
439 pszDescription =
argv[
i];
445 pszWorkingDir =
argv[
i];
451 pszCmdLineArgs =
argv[
i];
463 unsigned Data4Tmp[8],
j;
467 sscanf(
argv[
i],
"{%8x-%4hx-%4hx-%2x%2x-%2x%2x%2x%2x%2x%2x}",
469 &Data4Tmp[0], &Data4Tmp[1], &Data4Tmp[2], &Data4Tmp[3],
470 &Data4Tmp[4], &Data4Tmp[5], &Data4Tmp[6], &Data4Tmp[7]);
471 for (
j = 0;
j < 8; ++
j)
483 if (!pszTarget || bHelp)
485 printf(
"Usage: %s [-h][-v][-o path][-u][-d descr][-w path][-c cmdline_args][-i [icon_path[,nr]]][-g guid] target\n"
486 "-h\tShows this help.\n"
487 "-v\tEnables verbose mode for diagnostics.\n"
488 "-o path\tSets the output path.\n"
489 "-u\tCreates a Unicode-aware shortcut.\n"
490 "-d descr\tSets the shortcut description.\n"
491 "-w path\tSets the working directory for the executable.\n"
492 "-c cmdline_args\tSets the command-line arguments passed to the program.\n"
493 "-i [icon_path[,nr]]\tSets the icon path and optionally its index. If only an index is given (but no path), the target file is used instead.\n"
494 "-m\tStart minimized.\n"
495 "-g guid\tSets the GUID to which the target path is relative. Default value is MyComputer GUID.\n"
496 "target\tAbsolute or relative to GUID specified with the -g option path.\n",
argv[0]);
514 dwTmp =
strtol(pszIcon, &endptr, 0);
515 if (endptr && endptr != pszIcon)
529 if (endptr && endptr != (
ptr+1))
540 trace(
"OutputPath = %s\n"
545 "Icon = %s (%d)\n\n",
546 pszOutputPath, pszTarget, pszDescription,
547 pszWorkingDir, pszCmdLineArgs,
548 (pszIcon == (
char*)1) ? pszTarget : pszIcon,
IconIndex);
553 printf(
"Failed to open %s\n", pszOutputPath);
560 Header.Guid = CLSID_ShellLink;
584 Header.Flags &= ~LINK_ID_LIST;
587 Header.Flags &= ~LINK_RELATIVE_PATH;
604 trace(
"Header.Flags = 0x%08x\n"
605 "Header.IconIndex = %d\n"
606 "Header.ShowCmd = %u\n",
616 unsigned int cbListSize =
sizeof(IdListGuid) +
sizeof(
uint16_t);
619 const char *pszOrgTarget = pszTarget;
620 size_t specialPathLen = 0;
627 CsidlBlock.
cbSize =
sizeof(CsidlBlock);
632 pszTarget = targetpath;
636 if (pszName[0] && pszName[0] !=
':' && pszName[1] ==
':')
638 cbListSize +=
sizeof(IdListDrive);
650 if (
cchName != 1 || pszName[0] !=
'.')
654 cbListSize +=
sizeof(IdListFile) + (
cchName + 1) + 1;
657 if (special && ((pszName+
cchName)-pszTarget == specialPathLen))
661 pCsidlBlock = &CsidlBlock;
673 IdListGuid.
Size =
sizeof(IdListGuid);
681 if (
isalpha(pszName[0]) && pszName[1] ==
':')
683 memset(&IdListDrive, 0,
sizeof(IdListDrive));
684 IdListDrive.
Size =
sizeof(IdListDrive);
687 fwrite(&IdListDrive,
sizeof(IdListDrive), 1,
pFile);
699 if (
cchName != 1 || pszName[0] !=
'.')
701 memset(&IdListFile, 0,
sizeof(IdListFile));
704 IdListFile.
Size =
sizeof(IdListFile) + (
cchName + 1) + 1;
730 pszTarget = targetpath;
735 if (pszIcon == (
char*)1)
740 memset(&SzLinkBlock, 0,
sizeof(SzLinkBlock));
741 SzLinkBlock.
cbSize =
sizeof(SzLinkBlock);
748 pSzLinkBlock = &SzLinkBlock;
753 memset(&SzIconBlock, 0,
sizeof(SzIconBlock));
754 SzIconBlock.
cbSize =
sizeof(SzIconBlock);
761 pSzIconBlock = &SzIconBlock;
786 fwrite(pCsidlBlock,
sizeof(*pCsidlBlock), 1,
pFile);
788 fwrite(pSzLinkBlock,
sizeof(*pSzLinkBlock), 1,
pFile);
790 fwrite(pSzIconBlock,
sizeof(*pSzIconBlock), 1,
pFile);
int CDECL vprintf(const char *format, va_list valist)
int CDECL fclose(FILE *file)
FILE *CDECL fopen(const char *path, const char *mode)
int CDECL fputc(int c, FILE *file)
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
_ACRTIMP __msvcrt_long __cdecl strtol(const char *, char **, int)
_ACRTIMP char *__cdecl strchr(const char *, int)
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
_ACRTIMP char *__cdecl strrchr(const char *, int)
static const WCHAR IconIndex[]
GLuint GLuint GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static bool has_env_variables(const char *str)
static const struct SPECIALFOLDER * get_special_folder(const char *target)
struct _EXP_SZ_LINK EXP_SZ_LINK
struct _ID_LIST_GUID ID_LIST_GUID
struct _LNK_HEADER LNK_HEADER
struct _LNK_LOCATOR_INFO LNK_LOCATOR_INFO
#define LINK_RELATIVE_PATH
static const struct SPECIALFOLDER g_specialfolders[]
struct _EXP_SPECIAL_FOLDER EXP_SPECIAL_FOLDER
#define LINK_CMDLINE_ARGS
struct _FILETIME * PFILETIME
struct _FILETIME FILETIME
#define EXP_SPECIAL_FOLDER_SIG
static bool is_path_separator(char c)
struct _ID_LIST_FILE ID_LIST_FILE
static void write_string(FILE *pFile, bool bUnicode, const char *str)
static void strip_quotes_and_unescape_envvars(char **pstr)
#define REGITEMORDER_MYCOMPUTER
#define SLDF_HAS_EXP_ICON_SZ
struct _LNK_LOCAL_VOLUME_INFO LNK_LOCAL_VOLUME_INFO
#define SW_SHOWMINNOACTIVE
struct _ID_LIST_DRIVE ID_LIST_DRIVE
#define DEFINE_GUID2(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
size_t my_mbstowcs(wchar_t *wcstr, const char *mbstr, size_t count)
WCHAR szwTarget[MAX_PATH]
wchar_t szwTarget[MAX_PATH]
uint32_t VolumeNameOffset
uint32_t LocalBasePathnameOffset
uint32_t LocalVolumeInfoOffset
uint32_t RemainingPathnameOffset
uint32_t NetworkVolumeInfoOffset
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName