Skip to content

Commit

Permalink
Merge pull request #19 from ntoskrnl7/features/ntl
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
ntoskrnl7 authored Jun 20, 2022
2 parents f73faf8 + d683e34 commit 97abfaf
Show file tree
Hide file tree
Showing 26 changed files with 4,230 additions and 88 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,42 @@ jobs:
with:
submodules: true

- name: build x86
- name: build app x86
shell: cmd
run: ..\build.bat . x86
run: ..\build.bat app x86
working-directory: test

- name: build x64
- name: build app x64
shell: cmd
run: ..\build.bat . x64
run: ..\build.bat app x64
working-directory: test

- name: build ARM
- name: build app ARM
shell: cmd
run: ..\build.bat . ARM
run: ..\build.bat app ARM
working-directory: test

- name: build ARM64
- name: build app ARM64
shell: cmd
run: ..\build.bat . ARM64
run: ..\build.bat app ARM64
working-directory: test

- name: build driver x86
shell: cmd
run: ..\build.bat driver x86
working-directory: test

- name: build driver x64
shell: cmd
run: ..\build.bat driver x64
working-directory: test

- name: build driver ARM
shell: cmd
run: ..\build.bat driver ARM
working-directory: test

- name: build driver ARM64
shell: cmd
run: ..\build.bat driver ARM64
working-directory: test
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- vcxproj이 개발 환경에 종속되기 때문에 VS 버전이 바뀌면 일일이 수작업으로 수정해줘야함.
- x86에서 [이 코드](https://en.cppreference.com/w/cpp/language/throw#Example)를 실행하는 중 Hang이 발생함
- Microsoft의 소스 코드를 그대로 복사하여 상단에 자신의 라이센스 주석만 넣어서 프로젝트에 포함시킨것으로 보이며 라이센스 문제에서 자유롭지 못해보임
- 라이센스를 변조하는 것과 **(Microsoft CRT 및 STL 소스 코드를 재배포하는 행위는 허가되지 않은것으로 파악됨)**
- 라이센스를 변경하는 것과 **(Microsoft CRT 및 STL 소스 코드를 재배포하는 행위는 허가되지 않은것으로 파악됨)**

- [KTL](https://github.com/DymOK93/KTL)
- 장점
Expand Down Expand Up @@ -94,11 +94,13 @@ crtsys의 장점은 아래와 같습니다.
- 14.26.28801
- 14.29.30133
- 14.31.31103
- Windows Kit
- Windows Kit (SDK, WDK)
- 10.0.17763.0
- 10.0.18362.0
- 10.0.22000.0

SDK와 WDK의 버전이 다르면 빌드가 실패할 가능성이 높으므로 **가능하다면 SDK와 WDK의 버전이 같은 환경에서 빌드하는것을 권장합니다.**

## Goal

이 프로젝트는 커널 드라이벌르 작성할 때, 응용 프로그램에서 C++ 및 STL을 사용하는 것에 근접한 개발 경험을 제공하는것을 목표로합니다.
Expand Down Expand Up @@ -164,18 +166,24 @@ crtsys의 장점은 아래와 같습니다.
- ntl::driver
- DRIVER_OBJECT에 대한 클래스
- 기능
- [x] DriverUnload [(tested)](./test/src/main.cpp#L25)
- [x] DriverUnload [(tested)](./test/driver/src/main.cpp#L30)
- [ ] DriverDispatch
- ntl::driver_main [(tested)](./test/src/main.cpp#L21)
- ntl::driver_main [(tested)](./test/driver/src/main.cpp#L22)
- C++ 용 드라이버 진입점
- ntl::expand_stack 함수로 스택을 최대 크기로 확장하여 호출됩니다.
- ntl::rpc
- User Mode App과 Kernel Driver간 손쉬운 통신 방법을 제공합니다.
- ntl::rpc::server [(tested)](./test/common/rpc/server.hpp) [(tested)](./test/common/rpc/procedures.cpp)
- ntl::rpc::client [(tested)](./test/common/rpc/client.hpp) [(tested)](./test/common/rpc/procedures.cpp)
- 데이터 직렬화 부분은 직접 구현하기에는 시간이 부족하여 아래 프로젝트의 내용을 참고하엿습니다. 감사합니다! :-)
- [Eyal Z/zpp serializer](https://github.com/eyalz800/serializer)

## Build

이 프로젝트를 직접 빌드하여 lib와 include를 사용하시려면 Microsoft STL 사용을 위해서 포함 경로 설정 및 전처리기 설정 등 복잡한 사전 작업이 필요하므로 **직접 빌드하여 사용하는것보다는 [Usage](#usage)을 참고하여 CPM을 통해서 사용하시는것을 권장합니다.**

그리고 SDK와 WDK의 버전이 다르면 빌드가 실패할 가능성이 높으므로
**가능하다면 SDK와 WDK의 버전이 같은 환경에서 빌드하는것을 권장합니다.**
<details>
<summary>빌드 방법 보기</summary>

빌드 방법은 아래와 같습니다.

Expand All @@ -202,57 +210,50 @@ build.bat . x64 release
lib 디렉토리와 include 디렉토리를 타 프로젝트에서 사용하시면 됩니다.
이 라이브러리를 사용할 프로젝트의 전처리기 정의나 포함 경로 설정 등 프로젝트 설정은 [CMakeLists.txt](./CMakeLists.txt)에서 PUBLIC으로 설정된 항목들을 참고하여 설정하시기 바랍니다.

</details>

## Test

1. 아래 명령을 수행하여 라이브러리 및 테스트 코드를 빌드하시기 바랍니다.

```Batch
git clone https://github.com/ntoskrnl7/crtsys
cd crtsys/test
cmake -S . -B build_x64
cmake --build build_x64
cmake -S . -B build_x86 -A Win32
cmake --build build_x86
cmake -S . -B build_ARM -A ARM
cmake --build build_ARM
cmake -S . -B build_ARM64 -A ARM64
cmake --build build_ARM64
```
혹은
```Batch
git clone https://github.com/ntoskrnl7/crtsys
cd crtsys/test
build.bat . x86
build.bat . x64
build.bat . ARM
build.bat . ARM64
cd crtsys\test\build.bat
```
혹은 아래 명령을 수행하시면 지원되는 모든 아키텍쳐에 대해서 Debug, Release 구성을 모두 빌드합니다.
```Batch
git clone https://github.com/ntoskrnl7/crtsys
cd crtsys/test
build_all.bat test
build_all.bat test\app
build_all.bat test\driver
```
2. build/Debug/crtsys_test.sys를 설치 및 로드하시기 바랍니다.
2. build\Debug\crtsys_test.sys를 설치 및 로드하시기 바랍니다.
x64 : build_x64/Debug/crtsys_test.sys
x86 : build_x86/Debug/crtsys_test.sys
ARM : build_ARM/Debug/crtsys_test.sys
ARM64 : build_ARM64/Debug/crtsys_test.sys
- driver
x64 : test\driver\build_x64\Debug\crtsys_test.sys
x86 : test\driver\build_x86\Debug\crtsys_test.sys
ARM : test\driver\build_ARM\Debug\crtsys_test.sys
ARM64 : test\driver\build_ARM64\Debug\crtsys_test.sys
- app
x64 : test\driver\build_x64\Debug\crtsys_test_app.sys
x86 : test\driver\build_x86\Debug\crtsys_test_app.sys
ARM : test\driver\build_ARM\Debug\crtsys_test_app.sys
ARM64 : test\driver\build_ARM64\Debug\crtsys_test_app.sys
```batch
sc create CrtSysTest binpath= "빌드된 crtsys_test.sys의 전체 경로" displayname= "crtsys test" start= demand type= kernel
sc start CrtSysTest
crtsys_test.app.exe
sc stop CrtSysTest
sc delete CrtSysTest
```

3. 정상적으로 로드/언로드가 되었다면 테스트 성공한 것이며, 테스트 내용은 DebugView나 WinDbg를 통해서 확인 가능합니다.
3. 정상적으로 로드, Google Test 통과/언로드가 되었다면 테스트 성공한 것이며, 테스트 내용은 DebugView나 WinDbg를 통해서 확인 가능합니다.

## Usage

Expand Down Expand Up @@ -297,16 +298,16 @@ CMake를 사용하는것을 권장합니다.
```CMake
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(crtsys_test LANGUAGES C)
project(crtsys_test LANGUAGES C CXX)
include(cmake/CPM.cmake)
set(CRTSYS_NTL_MAIN ON) # use ntl::main
CPMAddPackage("gh:ntoskrnl7/[email protected].5")
CPMAddPackage("gh:ntoskrnl7/[email protected].6")
include(${crtsys_SOURCE_DIR}/cmake/CrtSys.cmake)
# add driver
crtsys_add_driver(crtsys_test main.cpp)
crtsys_add_driver(crtsys_test src/main.cpp)
```
- src/main.cpp
Expand Down Expand Up @@ -364,4 +365,3 @@ CMake를 사용하는것을 권장합니다.
- CMake Install 구현
- 아직 구현되지 않은 C++ 및 STL 기능 구현
- Visual Studio 2017의 CRT 소스 코드 빌드
- 커널 드라이버와 사용자 프로세스 간 통신 기능
2 changes: 1 addition & 1 deletion include/.internal/version
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Environment:

#define CRTSYS_VERSION_MAJOR 0
#define CRTSYS_VERSION_MINOR 1
#define CRTSYS_VERSION_PATCH 5
#define CRTSYS_VERSION_PATCH 6

#endif // _CRTSYS_VERSION_
Loading

0 comments on commit 97abfaf

Please sign in to comment.