Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.18.4)

project(lddw
VERSION "0.1.0"
DESCRIPTION "An ldd (List Dynamic Dependencies) implementation for Windows."
HOMEPAGE_URL "https://github.com/Sharp0802/lddw"
LANGUAGES "C"
)

set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_VISIBILITY_PRESET hidden)

set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/inc")

if(MSVC)
add_compile_options(
"/W4"
"/WX"
)
else()
add_compile_options(
"-pedantic"
"-Wall"
"-Wextra"
)
endif()

add_subdirectory(src)
2 changes: 0 additions & 2 deletions project/inc/fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <tchar.h>
#include <tlhelp32.h>

#include <unistd.h>

#undef ERROR

/* https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation */
Expand Down
22 changes: 22 additions & 0 deletions project/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
add_executable(lddw
"main.c"

"dict.c"
"ldd.c"
"log.c"
)

target_compile_definitions(lddw
PRIVATE
"_UNICODE"
"UNICODE"
)

target_include_directories(lddw
PRIVATE
${INCLUDE_DIR}
)

set_target_properties(lddw PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
)
6 changes: 3 additions & 3 deletions project/src/ldd.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ int __impl_static_ldd(struct LDD_ARGS args, const LPCVOID fdat, const LPCWSTR fn
if ((strncmp("ext-", namea, 4) == 0 || strncmp("api-", namea, 4) == 0) && !args.bViewAll)
continue;

MultiByteToWideChar(CP_UTF8, 0, namea, strlen(namea) + 1, namew, MAX_PATH_W);
MultiByteToWideChar(CP_UTF8, 0, namea, (int)strlen(namea) + 1, namew, MAX_PATH_W);
}

// check duplicates if `--flatten` enabled
if (args.bFlatten && !dict__add(dict, namew, (wcslen(namew) + 1) * sizeof(WCHAR)))
if (args.bFlatten && !dict__add(dict, namew, (int)(wcslen(namew) + 1) * sizeof(WCHAR)))
continue;

// print indents
Expand Down Expand Up @@ -219,7 +219,7 @@ int __findlib(const LPCWSTR fname, const LPWSTR fpath, DWORD size)
size_t namelen = wcslen(name);
if (namelen < MAX_PATH_W)
{
found = wcsnicmp(buf, name, namelen) == 0 && *(buf + namelen) == L'\\';
found = _wcsnicmp(buf, name, namelen) == 0 && *(buf + namelen) == L'\\';
if (found)
{
WCHAR tmpfile[MAX_PATH_W];
Expand Down
2 changes: 1 addition & 1 deletion project/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define ARGBASE_MAX INT32_MAX

int mainCRTStartup(void)
int main(void)
{
int ret = 0;

Expand Down