Skip to content

Commit

Permalink
Build: Add ARM64 target
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Jul 13, 2024
1 parent 586fe7d commit ac805ce
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 22 deletions.
6 changes: 6 additions & 0 deletions SimpleWindowSwitcher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Debug|arm64 = Debug|arm64
Release|x64 = Release|x64
Release|x86 = Release|x86
Release|arm64 = Release|arm64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Debug|x64.ActiveCfg = Debug|x64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Debug|x64.Build.0 = Debug|x64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Debug|x86.ActiveCfg = Debug|Win32
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Debug|x86.Build.0 = Debug|Win32
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Debug|arm64.ActiveCfg = Debug|ARM64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Debug|arm64.Build.0 = Debug|ARM64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Release|x64.ActiveCfg = Release|x64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Release|x64.Build.0 = Release|x64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Release|x86.ActiveCfg = Release|Win32
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Release|x86.Build.0 = Release|Win32
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Release|arm64.ActiveCfg = Release|ARM64
{FCDC9E89-976E-40D0-A1D0-2BD773720742}.Release|arm64.Build.0 = Release|ARM64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
61 changes: 61 additions & 0 deletions SimpleWindowSwitcher/SimpleWindowSwitcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
Expand Down Expand Up @@ -52,6 +60,19 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
Expand All @@ -69,6 +90,12 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
Expand Down Expand Up @@ -144,6 +171,40 @@
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.c" />
<ClCompile Include="sws_error.c" />
Expand Down
2 changes: 1 addition & 1 deletion SimpleWindowSwitcher/sws_WindowHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extern pIsCoreWindow _sws_IsCoreWindow;

typedef HWND(WINAPI* pCreateWindowInBand)(
_In_ DWORD dwExStyle,
_In_opt_ ATOM atom,
_In_opt_ LPCWSTR lpClassName,
_In_opt_ LPCWSTR lpWindowName,
_In_ DWORD dwStyle,
_In_ int X,
Expand Down
9 changes: 6 additions & 3 deletions SimpleWindowSwitcher/sws_WindowSwitcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void _sws_WindowSwitcher_Wineventproc(
}
}

static DWORD WINAPI _sws_WindowSwitcher_Calculate(sws_WindowSwitcher* _this, HWND* pOldHWNDs, DWORD cntOldHWNDs, DWORD dwOldIndex)
static void WINAPI _sws_WindowSwitcher_Calculate(sws_WindowSwitcher* _this, HWND* pOldHWNDs, DWORD cntOldHWNDs, DWORD dwOldIndex)
{
HWND hWndInitial = (_this->mode == SWS_WINDOWSWITCHER_LAYOUTMODE_FULL && _this->layout.bIncludeWallpaper && _this->layout.bWallpaperAlwaysLast && _sws_WindowHelpers_IsDesktopRaised() && !IsWindowVisible(_this->hWnd)) ? _this->layout.hWndWallpaper : NULL;

Expand Down Expand Up @@ -1795,6 +1795,7 @@ static DWORD _sws_WindowSwitcher_EndTaskThreadProc(sws_WindowSwitcher_EndTaskThr
PostMessageW(params->hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
}
free(params);
return 0;
}

static LRESULT _sws_WindowsSwitcher_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Expand Down Expand Up @@ -2029,7 +2030,7 @@ static LRESULT _sws_WindowsSwitcher_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
int bContains = -1;
for (int i = 0; i < _this->pHWNDList.cbSize; ++i)
{
if (pHWNDList[i].hWnd == lParam)
if (pHWNDList[i].hWnd == (HWND)lParam)
{
bContains = i;
break;
Expand Down Expand Up @@ -2230,7 +2231,7 @@ static LRESULT _sws_WindowsSwitcher_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam,

if (wParam == HSHELL_WINDOWCREATED || wParam == HSHELL_WINDOWACTIVATED || wParam == HSHELL_RUDEAPPACTIVATED)
{
if (IsWindowVisible(_this->hWnd) && lParam != _this->hWnd && sws_WindowHelpers_IsAltTabWindow(lParam))
if (IsWindowVisible(_this->hWnd) && (HWND)lParam != _this->hWnd && sws_WindowHelpers_IsAltTabWindow(lParam))
{
HDPA hdpa = DPA_Create(SWS_VECTOR_CAPACITY);
EnumWindows(sws_WindowHelpers_AddAltTabWindowsToTimeStampedHWNDList, hdpa);
Expand Down Expand Up @@ -2716,6 +2717,7 @@ static DWORD _sws_WindowSwitcher_FlashAnimationProcedure(sws_WindowSwitcher* _th
sws_nanosleep((LONGLONG)SWS_WINDOWSWITCHER_ANIMATOR_FLASH_DELAY * (LONGLONG)10000);
}
}
return 0;
}

static DWORD _sws_WindowSwitcher_ShowAsyncProcedure(sws_WindowSwitcher* _this)
Expand All @@ -2739,6 +2741,7 @@ static DWORD _sws_WindowSwitcher_ShowAsyncProcedure(sws_WindowSwitcher* _this)
}
}
}
return 0;
}

static sws_error_t _sws_WindowSwitcher_RegisterWindowClass(sws_WindowSwitcher* _this)
Expand Down
34 changes: 16 additions & 18 deletions SimpleWindowSwitcher/sws_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

void sws_error_PrintStackTrace()
{
#if _WIN64
#if defined(_M_X64)
DWORD machine = IMAGE_FILE_MACHINE_AMD64;
#else
#elif defined(_M_ARM64)
DWORD machine = IMAGE_FILE_MACHINE_ARM64;
#elif defined(_M_IX86)
DWORD machine = IMAGE_FILE_MACHINE_I386;
#endif
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
Expand All @@ -22,18 +24,23 @@ void sws_error_PrintStackTrace()
context.ContextFlags = CONTEXT_FULL;
RtlCaptureContext(&context);

#if _WIN64
STACKFRAME frame;
ZeroMemory(&frame, sizeof(STACKFRAME));
#if defined(_M_X64)
frame.AddrPC.Offset = context.Rip;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context.Rbp;
frame.AddrFrame.Mode = AddrModeFlat;
frame.AddrStack.Offset = context.Rsp;
frame.AddrStack.Mode = AddrModeFlat;
#else
STACKFRAME frame;
ZeroMemory(&frame, sizeof(STACKFRAME));
#elif defined(_M_ARM64)
frame.AddrPC.Offset = context.Pc;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context.Fp;
frame.AddrFrame.Mode = AddrModeFlat;
frame.AddrStack.Offset = context.Sp;
frame.AddrStack.Mode = AddrModeFlat;
#elif defined(_M_IX86)
frame.AddrPC.Offset = context.Eip;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context.Ebp;
Expand All @@ -47,23 +54,14 @@ void sws_error_PrintStackTrace()
{
printf("[%3d] = [0x%p] :: ", i, frame.AddrPC.Offset);

#if _WIN64
DWORD64 moduleBase = 0;
#else
DWORD moduleBase = 0;
#endif

moduleBase = SymGetModuleBase(process, frame.AddrPC.Offset);
UINT_PTR moduleBase = SymGetModuleBase(process, frame.AddrPC.Offset);

char moduelBuff[MAX_PATH];
if (moduleBase && GetModuleFileNameA((HINSTANCE)moduleBase, moduelBuff, MAX_PATH))
{
}
#if _WIN64
DWORD64 offset = 0;
#else
DWORD offset = 0;
#endif

UINT_PTR offset = 0;
char symbolBuffer[sizeof(IMAGEHLP_SYMBOL) + 255];
PIMAGEHLP_SYMBOL symbol = (PIMAGEHLP_SYMBOL)symbolBuffer;
symbol->SizeOfStruct = (sizeof(IMAGEHLP_SYMBOL)) + 255;
Expand Down

0 comments on commit ac805ce

Please sign in to comment.