Skip to content

Commit 96aa1ee

Browse files
authored
[LNKTOOL][SHELL32] Add utility to create/dump .lnk files (reactos#7745)
Unlike mkshelllink, this uses the native COM interface to create the link.
1 parent 75c0dc0 commit 96aa1ee

File tree

7 files changed

+919
-10
lines changed

7 files changed

+919
-10
lines changed

dll/win32/shell32/CShellLink.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static BOOL Stream_LoadVolume(LOCAL_VOLUME_INFO *vol, CShellLink::volume_info *v
544544
INT len = vol->dwSize - vol->dwVolLabelOfs;
545545

546546
LPSTR label = (LPSTR)vol;
547-
label += vol->dwVolLabelOfs;
547+
label += vol->dwVolLabelOfs; // FIXME: 0x14 Unicode
548548
MultiByteToWideChar(CP_ACP, 0, label, len, volume->label, _countof(volume->label));
549549

550550
return TRUE;
@@ -595,7 +595,7 @@ static HRESULT Stream_LoadLocation(IStream *stm,
595595
/* if there's a local path, load it */
596596
DWORD n = loc->dwLocalPathOfs;
597597
if (n && n < loc->dwTotalSize)
598-
*path = Stream_LoadPath(&p[n], loc->dwTotalSize - n);
598+
*path = Stream_LoadPath(&p[n], loc->dwTotalSize - n); // FIXME: Unicode offset (if present)
599599

600600
TRACE("type %d serial %08x name %s path %s\n", volume->type,
601601
volume->serial, debugstr_w(volume->label), debugstr_w(*path));
@@ -850,7 +850,7 @@ static HRESULT Stream_WriteString(IStream* stm, LPCWSTR str)
850850
* Figure out how Windows deals with unicode paths here.
851851
*/
852852
static HRESULT Stream_WriteLocationInfo(IStream* stm, LPCWSTR path,
853-
CShellLink::volume_info *volume)
853+
CShellLink::volume_info *volume) // FIXME: Write Unicode strings
854854
{
855855
LOCAL_VOLUME_INFO *vol;
856856
LOCATION_INFO *loc;
@@ -913,6 +913,7 @@ HRESULT STDMETHODCALLTYPE CShellLink::Save(IStream *stm, BOOL fClearDirty)
913913

914914
m_Header.dwSize = sizeof(m_Header);
915915
m_Header.clsid = CLSID_ShellLink;
916+
m_Header.dwReserved3 = m_Header.dwReserved2 = m_Header.wReserved1 = 0;
916917

917918
/* Store target attributes */
918919
WIN32_FIND_DATAW wfd = {};
@@ -934,8 +935,9 @@ HRESULT STDMETHODCALLTYPE CShellLink::Save(IStream *stm, BOOL fClearDirty)
934935
* already set in accordance by the different mutator member functions.
935936
* The other flags will be determined now by the presence or absence of data.
936937
*/
937-
m_Header.dwFlags &= (SLDF_RUN_WITH_SHIMLAYER | SLDF_RUNAS_USER |
938-
SLDF_RUN_IN_SEPARATE | SLDF_HAS_DARWINID |
938+
UINT NT6SimpleFlags = LOBYTE(GetVersion()) > 6 ? (0x00040000 | 0x00400000 | 0x00800000 | 0x02000000) : 0;
939+
m_Header.dwFlags &= (SLDF_RUN_WITH_SHIMLAYER | SLDF_RUNAS_USER | SLDF_RUN_IN_SEPARATE |
940+
SLDF_HAS_DARWINID | SLDF_FORCE_NO_LINKINFO | NT6SimpleFlags |
939941
#if (NTDDI_VERSION < NTDDI_LONGHORN)
940942
SLDF_HAS_LOGO3ID |
941943
#endif
@@ -2488,14 +2490,11 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetFlags(DWORD *pdwFlags)
24882490

24892491
HRESULT STDMETHODCALLTYPE CShellLink::SetFlags(DWORD dwFlags)
24902492
{
2491-
#if 0 // FIXME!
2493+
if (m_Header.dwFlags == dwFlags)
2494+
return S_FALSE;
24922495
m_Header.dwFlags = dwFlags;
24932496
m_bDirty = TRUE;
24942497
return S_OK;
2495-
#else
2496-
FIXME("\n");
2497-
return E_NOTIMPL;
2498-
#endif
24992498
}
25002499

25012500
/**************************************************************************

modules/rosapps/applications/devutils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ add_subdirectory(createspec)
33
add_subdirectory(gdb2)
44
add_subdirectory(gdihv)
55
add_subdirectory(genguid)
6+
add_subdirectory(lnktool)
67
add_subdirectory(nls2txt)
78
add_subdirectory(shimdbg)
89
add_subdirectory(shimtest_ros)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
add_executable(lnktool lnktool.cpp lnktool.rc)
3+
4+
set_module_type(lnktool win32cui UNICODE)
5+
target_link_libraries(lnktool uuid)
6+
add_importlibs(lnktool ole32 comctl32 shell32 shlwapi advapi32 user32 msvcrt kernel32)
7+
add_cd_file(TARGET lnktool DESTINATION reactos/system32 FOR all)

0 commit comments

Comments
 (0)