{"id":17287447,"url":"https://github.com/utoni/mingw-w64-dpp","last_synced_at":"2025-04-14T11:06:49.153Z","repository":{"id":40455557,"uuid":"355345788","full_name":"utoni/mingw-w64-dpp","owner":"utoni","description":"\"Mingw64 Driver Plus Plus\": Mingw64, C++, DDK and (EA)STL made easy!","archived":false,"fork":false,"pushed_at":"2025-02-03T14:37:46.000Z","size":2068,"stargazers_count":38,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T11:06:43.731Z","etag":null,"topics":["cpp","ddk","driver","eastl","mingw","mingw64","stl","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utoni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-06T22:29:13.000Z","updated_at":"2025-03-23T12:34:18.000Z","dependencies_parsed_at":"2024-05-28T22:41:39.728Z","dependency_job_id":"07a2a1c1-c066-4c2f-a20e-b00be6868069","html_url":"https://github.com/utoni/mingw-w64-dpp","commit_stats":{"total_commits":148,"total_committers":5,"mean_commits":29.6,"dds":0.3851351351351351,"last_synced_commit":"6763f3510099db3d2f6272cdaf957f8beeddf842"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utoni%2Fmingw-w64-dpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utoni%2Fmingw-w64-dpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utoni%2Fmingw-w64-dpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utoni%2Fmingw-w64-dpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utoni","download_url":"https://codeload.github.com/utoni/mingw-w64-dpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868767,"owners_count":21174757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","ddk","driver","eastl","mingw","mingw64","stl","windows"],"created_at":"2024-10-15T10:02:38.654Z","updated_at":"2025-04-14T11:06:49.133Z","avatar_url":"https://github.com/utoni.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://github.com/utoni/mingw-w64-dpp/actions/workflows/build.yml/badge.svg \"Github Actions\")](https://github.com/utoni/mingw-w64-dpp/actions/workflows/build.yml)\n[![Gitlab-CI](https://gitlab.com/utoni/mingw-w64-ddk-template/badges/main/pipeline.svg \"Gitlab-CI: main branch\")](https://gitlab.com/utoni/mingw-w64-ddk-template/-/pipelines)\n[![Circle-CI](https://circleci.com/gh/utoni/mingw-w64-dpp.svg?style=shield \"Circle-CI\")](https://app.circleci.com/pipelines/github/utoni/mingw-w64-dpp)\n\n# Mingw64 Driver Plus Plus\n\nA Windows kernel driver C/C++ SDK using Mingw64.\n\nIt provides also some examples and a feature complete STL including your\nbeloved containers.\n\nYou will need an modern Mingw64-GCC toolchain.\nDo not use any broken toolchains like the one shipped with debian-10.\nMingw64 for debian-11 seems to work, but is not well tested. Mingw64 for debian-12 untested.\nInstead either use Zeranoe's build script with `make -C [path-to-this-repo] -f Makefile.deps all` (same as `make -C [path-to-this-repo] deps`) or use your own.\n\n## What?\n\n1. `examples/dpp-template`: plain and stupid ddk C example\n2. `examples/dpp-template-cplusplus`: same, but written in C++, including a very complex class and some MT\n3. `examples/dpp-template-cplusplus-EASTL`: C++ example w/ (EA)STL integration, basicially everything usable except for VEH and assertions.\n\n`examples/dpp-template-cplusplus-EASTL` supports `BUILD_NATIVE`!\nYou can build and run it on your native Linux either with the other examples e.g. `make examples`, build only native executables `make -C examples DPP_ROOT=\"$(realpath .)\" BUILD_NATIVE=1` in the top-level directory or directly build it from the examples directory with `make DPP_ROOT=\"$(realpath ..)\" BUILD_NATIVE=1`.\n\n## Build and Test\n\nBuild all examples with a Mingw64 toolchain using Zeranoe's build script:\n\n```\nmake -C [path-to-this-repo] -f Makefile.deps all # build toolchain, CRT, CRT++ and EASTL\nmake -C [path-to-this-repo] all # build examples\n```\n\nBuild all examples with your own Mingw64 toolchain:\n\n``\nmake all CC=path/to/bin/x86_64-w64-mingw32-gcc CXX=path/to/bin/x86_64-w64-mingw32-g++ DDK_INCLUDE_DIR=path/to/include/ddk\n``\n\n## HowTo use it in your own project\n\nAt the moment only a **GMake** build system is supported.\nA minimal working **Makefile** for your own project could look alike:\n\n```make\nifndef DPP_ROOT\n$(error DPP_ROOT is undefined)\nendif\n\ninclude $(DPP_ROOT)/Makefile.inc\n\nDRIVER_NAME = Driver\nDRIVER_OBJECTS = $(DRIVER_NAME).opp\nDRIVER_TARGET = $(DRIVER_NAME).sys\n\n%.opp: %.cpp\n\t$(call BUILD_CPP_OBJECT,$\u003c,$@)\n\n$(DRIVER_TARGET): $(DRIVER_OBJECTS)\n\t$(call LINK_CPP_KERNEL_TARGET,$(DRIVER_OBJECTS),$@)\n```\n\nBuild it with: `make Driver.sys DPP_ROOT=[path/to/this/repository]`\n\nIt also possible to (self-)sign your driver and install your driver with:\n\n```make\ninstall: $(DRIVER_TARGET)\n    $(call INSTALL_EXEC_SIGN,$(DRIVER_TARGET))\n```\n\nYou can also add the toolchain to your path and use it for other projects w/o any Makefile blueprint:\n\n```\nmake -C [path-to-this-repo] -f Makefile.deps all\nsource [path-to-this-repo]/mingw-w64-sysroot/x86_64/activate.sh\n```\n\n### Packaging\n\nIt is possible to create `*.dpp` archives ready to get shipped.\nTo do this you need to call the `PACKAGE` macro.\nBut before you should install public header files with the `INSTALL_HEADERS` macro.\n\nSee the `Makefile` of [mingw-w64-ksocket](https://github.com/utoni/mingw-w64-ksocket.git) for an example.\n\n## The CRT and CRT++\n\nThis project uses a very very rudimentary CRT for C and C++ projects.\nPlease keep in mind that depending on what you want to do the CRT may lack features you are familiar with.\nUsually this will manifest in linker errors such as undefined references.\nMost of the time copy\u0026pasting missing libc/libgcc functions from various online sources should be sufficient.\n\nRemember: The CRT/CRT++ **sets a driver unload function** meaning that code .e.g.:\n\n```C\nNTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT * DriverObject, _In_ PUNICODE_STRING RegistryPath)\n{\n    DriverObject-\u003eDriverUnload = MyDriverUnload;\n}\n```\n\n**must not** used. Overwriting `DriverObject-\u003eDriverUnload` with your own function may BSOD.\nInstead the function `DriverUnload` will be called.\nMake sure that the symbol `DriverUnload` exists and has the usual ddk function signature:\n`void DriverUnload(_In_ struct _DRIVER_OBJECT * DriverObject)`.\nThis is required to make ctors/dtors work without calling additional functions in `DriverEntry` / `DriverUnload`.\n\nDo not forget to disable `C++ name mangeling` if your driver source which contains the `DriverEntry` and `DriverUnload` symbols is compiled with `g++`:\n\n```C++\nextern \"C\" {\nNTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath)\n{\n    // ...\n}\nVOID DriverUnload(_In_ struct _DRIVER_OBJECT *DriverObject)\n{\n    // ...\n}\n}\n```\n\n## Host EASTL/CRT/CRT++ Build\n\nIt is possible to build parts of the repository for your host distribution.\nTo do that simply type:\n\n``\nmake -C [path-to-this-repo] -f Makefile.deps -j1 all BUILD_NATIVE=1\n``\n\nThe results should be visible in `./CRT` and `EASTL-native-build`.\nIf you ran `make -C [path-to-this-repo] deps` before, everything is already done including the native build.\n\nYou can use the Host Build in your Makefile based project with:\n\n```make\nifndef DPP_ROOT\n$(error DPP_ROOT is undefined)\nendif\n\nifndef BUILD_NATIVE\ninclude $(DPP_ROOT)/Makefile.inc\nelse\ninclude $(DPP_ROOT)/Makefile.native.inc\nendif\n\n# Driver\nDRIVER_NAME = Driver\nDRIVER_OBJECTS = $(DRIVER_NAME).opp\nDRIVER_TARGET = $(DRIVER_NAME).sys\nDRIVER_LIBS =\nCFLAGS_$(DRIVER_NAME).opp =\nLDFLAGS_$(DRIVER_NAME).sys =\n\n# Userspace\nUSER_NAME = usa$(NAME_SUFFIX)\nUSER_OBJECTS = $(USER_NAME).opp\nUSER_TARGET = $(USER_NAME).exe\nUSER_LIBS =\nCFLAGS_$(USER_NAME).opp =\nLDFLAGS_$(USER_NAME).exe =\n\n# specify additional CFLAGS for kernel/user targets\nCUSTOM_CFLAGS = -I.\n\n%.opp: %.cpp\n\t$(call BUILD_CPP_OBJECT,$\u003c,$@)\n\n$(DRIVER_TARGET): $(DRIVER_OBJECTS)\n\t$(call LINK_CPP_KERNEL_TARGET,$(DRIVER_OBJECTS),$@)\n\n$(USER_TARGET): $(USER_OBJECTS)\n\t$(call LINK_CPP_USER_TARGET,$(USER_OBJECTS),$@)\n```\n\n[A simple and stupid project example.](https://github.com/utoni/mingw-w64-driver)\n\n## Driver Signing\n\nDriver signing can be done in two ways. Using a native `osslsigncode` executable or sign it manually on your Windows platform.\nThe first one is always done by calling the macro `INSTALL_EXEC_SIGN` from your own Makefile.\nThe latter one has to be done manually on your target Windows machine by running:\n\n1. `create_codesign_ca.bat` in DESTDIR (Administrator permission required to import CA/CERTs to the Windows certificate storage\n2. `*-sign-driver-on-windows.bat` e.g. `dpp-example-sign-driver-on-windows.bat` (no Administrator permissions required)\n\n*Note*: You still need to call the macro `INSTALL_EXEC_SIGN` from your own Makefile to create/install the batch files in DESTDIR.\n\n## Extending\n\nYou may reach a point where system functions, intrinsics or built-ins are required.\nFor system functions that can be retrieved via `MmGetSystemRoutineAddress`, you may use `CRT/gen_wrapper.sh` to create wrapper modules. These modules retrieve the desired functions during run-time, but will be available during link-time. An example is `ZwTraceControl`, which gets exported by `ntdll.dll`.\nEventually missing intrinsics/built-ins should be placed in `CRT/kcrt.c`.\n\n## Notes on SEH\n\nThere are some limitations regarding the use of MingW's SEH implementation in kernel mode.\nYou can not use it as you might have been known it from MSVC or MingW.\n\nPredefined statements `__try`, `__catch`, `__finally`, `__try1`, `__catch1`, etc. do **not** work!\n\nYou need to use something like:\n\n```C\n#include \u003cexcept.h\u003e\n\nint handler(_In_ EXCEPTION_POINTERS * ep)\n{\n    (void)ep;\n    return EXCEPTION_EXECUTE_HANDLER;\n}\n\n// ...\n\n__dpptry(handler, unique_identifier) {\n    *(int *)0 = 0;\n} __dppexcept(unique_identifier) {\n    DbgPrint(\"%s\\n\", \"Exception caught!\");\n} __dpptryend(unique_identifier);\n```\n\nSEH needs to be improved. Patches are welcome!\n\n## Known Issues\n\nUnfortunately, `eastl::to_string` does not work. See `CRT/eastl_compat.cpp` for more details.\nInstead, `#include \u003ceastl_compat.hpp\u003e` and use `::to_string` globals.\n\n## Thanks goes to:\n\n- [Zeranoe](https://github.com/Zeranoe/mingw-w64-build) for the Mingw64 build script\n- [sidyhe](https://github.com/sidyhe/dxx) for some copy paste ready CRT code\n- [liupengs](https://github.com/liupengs/Mini-CRT) helped me to fix the ctor/dtor issue\n\nand last but not least:\n\n- [EA](https://github.com/electronicarts/EASTL), bad company, good STL\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futoni%2Fmingw-w64-dpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futoni%2Fmingw-w64-dpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futoni%2Fmingw-w64-dpp/lists"}