From 4377d9304910603bda83f3861719209dab75b332 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 14 Nov 2022 17:18:55 -1000 Subject: [PATCH] SCP: Avoid compile errors when compiled with UNICODE defined On windows all platform specific APIs deliberately use ANSI APIs. Fix these few inconsistencies. --- sim_ether.c | 8 ++++---- sim_fio.c | 2 +- sim_serial.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sim_ether.c b/sim_ether.c index 121c1e6f..09b176a3 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -1325,11 +1325,11 @@ int load_pcap(void) { /* attempt to load DLL */ #ifdef _WIN32 if (1) { - BOOL(WINAPI *p_SetDllDirectory)(LPCTSTR); - UINT(WINAPI *p_GetSystemDirectory)(LPTSTR lpBuffer, UINT uSize); + BOOL(WINAPI *p_SetDllDirectory)(const char *); + UINT(WINAPI *p_GetSystemDirectory)(char * lpBuffer, UINT uSize); - p_SetDllDirectory = (BOOL(WINAPI *)(LPCTSTR)) GetProcAddress(GetModuleHandleA("kernel32.dll"), "SetDllDirectoryA"); - p_GetSystemDirectory = (UINT(WINAPI *)(LPTSTR, UINT)) GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetSystemDirectoryA"); + p_SetDllDirectory = (BOOL(WINAPI *)(const char *)) GetProcAddress(GetModuleHandleA("kernel32.dll"), "SetDllDirectoryA"); + p_GetSystemDirectory = (UINT(WINAPI *)(char *, UINT)) GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetSystemDirectoryA"); if (p_SetDllDirectory && p_GetSystemDirectory) { char npcap_path[512] = ""; diff --git a/sim_fio.c b/sim_fio.c index 539edf11..b600b914 100644 --- a/sim_fio.c +++ b/sim_fio.c @@ -1751,7 +1751,7 @@ if ((hFind = FindFirstFileA (cptr, &File)) != INVALID_HANDLE_VALUE) { strlcat (FileName, File.cFileName, sizeof (FileName)); stat (FileName, &filestat); entry (DirName, File.cFileName, FileSize, &filestat, context); - } while (FindNextFile (hFind, &File)); + } while (FindNextFileA (hFind, &File)); FindClose (hFind); } else diff --git a/sim_serial.c b/sim_serial.c index 9f68bbe6..2af12aa7 100644 --- a/sim_serial.c +++ b/sim_serial.c @@ -584,7 +584,7 @@ DWORD commsize = sizeof (commdefault); COMMTIMEOUTS cto; char win32name[1028]; -if (!GetDefaultCommConfig (name, &commdefault, &commsize)) { /* get default comm parameters */ +if (!GetDefaultCommConfigA (name, &commdefault, &commsize)) { /* get default comm parameters */ error = GetLastError (); /* function failed; get error */ if (error != ERROR_INVALID_PARAMETER) /* not a communications port name? */ @@ -594,8 +594,8 @@ if (!GetDefaultCommConfig (name, &commdefault, &commsize)) { /* get default c } snprintf (win32name, sizeof (win32name), "\\\\.\\%s", name); -hPort = CreateFile (win32name, GENERIC_READ | GENERIC_WRITE, /* open the port */ - 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); +hPort = CreateFileA (win32name, GENERIC_READ | GENERIC_WRITE, /* open the port */ + 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); if (hPort == INVALID_HANDLE_VALUE) { /* open failed? */ error = GetLastError (); /* get error code */