Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Sep 26, 2024
0 parents commit 7a1f869
Show file tree
Hide file tree
Showing 50 changed files with 2,638 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: MSBuild

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
SOLUTION_FILE_PATH: .\Source\KNSoft.MakeLifeEasier.sln

permissions:
contents: read

jobs:
build:
strategy:
matrix:
platform: [x64, x86, ARM64]
config: [Debug, Release]
fail-fast: false
runs-on: windows-latest
steps:
- name: Source checkout
uses: actions/checkout@main
with:
submodules: recursive
- name: Prepare MSBuild
uses: microsoft/setup-msbuild@main
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild ${{env.SOLUTION_FILE_PATH}} /restore /m /p:Configuration=${{matrix.config}} /p:Platform=${{matrix.platform}} /p:RestorePackagesConfig=true
- name: Run Unit Test (x64, x86)
if: ${{ matrix.platform == 'x64' || matrix.platform == 'x86' }}
working-directory: ${{env.GITHUB_WORKSPACE}}
run: .\Source\OutDir\${{matrix.platform}}\${{matrix.config}}\Test.exe -Run
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) KNSoft.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
77 changes: 77 additions & 0 deletions Source/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Visual Studio generated .editorconfig file with C++ settings.
root = true

[*.{c,c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]

charset = utf-8-bom
indent_style = space
indent_size = 4
end_of_line = crlf
insert_final_newline = true
max_line_length = 120

# Visual C++ Code Style settings

cpp_generate_documentation_comments = xml

# Visual C++ Formatting settings

cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = align_to_parenthesis
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = true
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = false
cpp_indent_goto_labels = leftmost_column
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = true
cpp_new_line_before_open_brace_namespace = new_line
cpp_new_line_before_open_brace_type = new_line
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = new_line
cpp_new_line_before_open_brace_lambda = new_line
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = true
cpp_new_line_close_brace_same_line_empty_function = true
cpp_new_line_before_catch = false
cpp_new_line_before_else = false
cpp_new_line_before_while_in_do_while = false
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = ignore
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = all_one_line_scopes
8 changes: 8 additions & 0 deletions Source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.vs
*.user

/packages
/OutDir
IntDir

/*.nupkg
10 changes: 10 additions & 0 deletions Source/Directory.Build.AfterCppDefault.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<OutDir>$(SolutionDir)OutDir\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>IntDir\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
</Project>
74 changes: 74 additions & 0 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<Project>
<!-- Customize builds -->
<PropertyGroup>
<ForceImportAfterCppDefaultProps>$(MsbuildThisFileDirectory)\Directory.Build.AfterCppDefault.props</ForceImportAfterCppDefaultProps>
</PropertyGroup>

<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ObjectFileName>$(IntDir)%(Directory)</ObjectFileName>
</ClCompile>
</ItemDefinitionGroup>

<!-- MSBuild variable to C/C++ macro -->
<ItemDefinitionGroup Condition="'$(ConfigurationType)' == 'Application'">
<ClCompile>
<PreprocessorDefinitions>MSB_CONFIGURATIONTYPE_EXE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(ConfigurationType)' == 'DynamicLibrary'">
<ClCompile>
<PreprocessorDefinitions>MSB_CONFIGURATIONTYPE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(ConfigurationType)' == 'StaticLibrary'">
<ClCompile>
<PreprocessorDefinitions>MSB_CONFIGURATIONTYPE_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(ConfigurationType)' == 'Utility'">
<ClCompile>
<PreprocessorDefinitions>MSB_CONFIGURATIONTYPE_UTILITY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>MSB_CONFIGURATION_NAME="$(ConfigurationName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_MSBUILD_VERSION="$(MSBuildVersion)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_VCTOOLS_VERSION="$(VCToolsVersion)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_PLATFORM_TOOLSET="$(PlatformToolset)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_PLATFORM_TOOLSET_VERSION="$(PlatformToolsetVersion)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_PLATFORM_TARGET_VERSION="$(PlatformTarget)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_TARGET_PLATFORM_VERSION="$(TargetPlatformVersion)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MSB_TARGET_PLATFORM_DISPLAY_NAME="$(TargetPlatformDisplayName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>

<!-- Use static default libraries -->
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>

<!-- Import $(MSBuildProjectName).Build.props if exists -->
<PropertyGroup>
<ProjectNameBuildPropsPath>$(MSBuildProjectDirectory)\$(MSBuildProjectName).Build.props</ProjectNameBuildPropsPath>
</PropertyGroup>
<Import Project="$(ProjectNameBuildPropsPath)" Condition="Exists('$(ProjectNameBuildPropsPath)')"/>

<!-- Import outer Directory.Build.props if exists -->
<PropertyGroup>
<OuterDirectoryBuildPropsPath>$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))</OuterDirectoryBuildPropsPath>
</PropertyGroup>
<Import Project="$(OuterDirectoryBuildPropsPath)" Condition="'$(OuterDirectoryBuildPropsPath)' != ''"/>
</Project>
54 changes: 54 additions & 0 deletions Source/KNSoft.MakeLifeEasier.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KNSoft.MakeLifeEasier", "KNSoft.MakeLifeEasier\KNSoft.MakeLifeEasier.vcxproj", "{4889E88D-A60F-418F-9737-989D84A1A73E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{E86C50FF-B196-4933-9FBA-5C31452C445B}"
ProjectSection(ProjectDependencies) = postProject
{4889E88D-A60F-418F-9737-989D84A1A73E} = {4889E88D-A60F-418F-9737-989D84A1A73E}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4889E88D-A60F-418F-9737-989D84A1A73E}.Debug|ARM64.ActiveCfg = Debug|ARM64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Debug|ARM64.Build.0 = Debug|ARM64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Debug|x64.ActiveCfg = Debug|x64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Debug|x64.Build.0 = Debug|x64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Debug|x86.ActiveCfg = Debug|Win32
{4889E88D-A60F-418F-9737-989D84A1A73E}.Debug|x86.Build.0 = Debug|Win32
{4889E88D-A60F-418F-9737-989D84A1A73E}.Release|ARM64.ActiveCfg = Release|ARM64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Release|ARM64.Build.0 = Release|ARM64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Release|x64.ActiveCfg = Release|x64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Release|x64.Build.0 = Release|x64
{4889E88D-A60F-418F-9737-989D84A1A73E}.Release|x86.ActiveCfg = Release|Win32
{4889E88D-A60F-418F-9737-989D84A1A73E}.Release|x86.Build.0 = Release|Win32
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Debug|ARM64.ActiveCfg = Debug|ARM64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Debug|ARM64.Build.0 = Debug|ARM64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Debug|x64.ActiveCfg = Debug|x64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Debug|x64.Build.0 = Debug|x64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Debug|x86.ActiveCfg = Debug|Win32
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Debug|x86.Build.0 = Debug|Win32
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Release|ARM64.ActiveCfg = Release|ARM64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Release|ARM64.Build.0 = Release|ARM64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Release|x64.ActiveCfg = Release|x64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Release|x64.Build.0 = Release|x64
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Release|x86.ActiveCfg = Release|Win32
{E86C50FF-B196-4933-9FBA-5C31452C445B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {74FBAC67-B2E9-47BD-B024-4898DA8CC6A2}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions Source/KNSoft.MakeLifeEasier/Dialog/Dialog.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../MakeLifeEasier.inl"
9 changes: 9 additions & 0 deletions Source/KNSoft.MakeLifeEasier/Dialog/Dialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "../MakeLifeEasier.h"

EXTERN_C_START

#define Dlg_MsgBox(Owner, Text, Title, Type) MessageBoxTimeoutW(Owner, Text, Title, Type, 0, -1)

EXTERN_C_END
80 changes: 80 additions & 0 deletions Source/KNSoft.MakeLifeEasier/Error/Message.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include "../MakeLifeEasier.inl"

_Success_(return != NULL)
PCWSTR
NTAPI
Err_GetWin32ErrorInfo(
_In_ ULONG Win32Error)
{
PVOID DllHandle;

return NT_SUCCESS(Sys_LoadDll(SysLibKernel32, &DllHandle)) ? PE_GetMessage(DllHandle, 0, Win32Error) : NULL;
}

_Success_(return != NULL)
PCWSTR
NTAPI
Err_GetNtStatusInfo(
_In_ NTSTATUS Status)
{
PVOID DllHandle;

return NT_SUCCESS(Sys_LoadDll(SysLibNtDll, &DllHandle)) ? PE_GetMessage(DllHandle, 0, Status) : NULL;
}

_Success_(return != NULL)
PCWSTR
NTAPI
Err_GetHResultInfo(
_In_ HRESULT HResult)
{
ULONG Facility, Code;

Facility = HRESULT_FACILITY(HResult);
Code = HRESULT_CODE(HResult);

if (Facility == FACILITY_WIN32)
{
return Err_GetWin32ErrorInfo(Code);
} else if ((ULONG)HResult & FACILITY_NT_BIT)
{
return Err_GetNtStatusInfo(Code);
}

return NULL;
}

VOID
NTAPI
Error_Win32ErrorMessageBox(
_In_opt_ HWND Owner,
_In_opt_ PCWSTR Title,
_In_ ULONG Win32Error)
{
Dlg_MsgBox(Owner,
Err_GetWin32ErrorInfo(Win32Error),
Title,
(Win32Error == ERROR_SUCCESS ? MB_ICONINFORMATION : MB_ICONERROR) | MB_OK);
}

VOID
NTAPI
Error_NtStatusMessageBox(
_In_opt_ HWND Owner,
_In_opt_ PCWSTR Title,
_In_ NTSTATUS Status)
{
UINT Type;

if (NT_ERROR(Status))
{
Type = MB_ICONERROR;
} else if (NT_WARNING(Status))
{
Type = MB_ICONWARNING;
} else
{
Type = MB_ICONINFORMATION;
}
Dlg_MsgBox(Owner, Err_GetNtStatusInfo(Status), Title, Type | MB_OK);
}
Loading

0 comments on commit 7a1f869

Please sign in to comment.