SergiusTheBest / FindWDK

CMake module for building drivers with Windows Development Kit (WDK)
BSD 3-Clause "New" or "Revised" License
251 stars 53 forks source link

How to use std::string? #14

Closed ddkwork closed 4 years ago

ddkwork commented 4 years ago

std::string a="333333": DbgPrint(a.c_str);

SergiusTheBest commented 4 years ago

You can't use STL in driver or Boost or any other user-mode libraries until they are ported to kernel mode.

ddkwork commented 4 years ago

在将STL移植到内核模式之前,不能在驱动程序或Boost或任何其他用户模式库中使用STL。

Some info: https://github.com/zer0mem/libc

https://github.com/wbenny/hvpp https://github.com/tandasat/DdiMon

They are used stl in kernel. I'd like use findwdk for build them,Thx.

ddkwork commented 4 years ago

I was created some stl packge like golang: Strings,bytes,hex,fmt....etc. Finally i can't write std::bind function..if findwd build stl well that's very cool.

like this: https://github.com/DiskGetor/CppSysLIB

SergiusTheBest commented 4 years ago

https://github.com/wbenny/hvpp doesn't use STL in a driver, it uses it only in a user-mode app. https://github.com/zer0mem/libc is a CRT for running C++ in kernel mode but it lacks exceptions and a lot of C++ libraries use exceptions. Also it's bad to use exceptions in kernel mode as it takes too much memory and can cause stack overflows (as stack is very limited in kernel mode). We experimented with that in the past. https://github.com/tandasat/DdiMon uses some parts of STL (like ). They take it from the standard MSVC path $(VC_IncludePath).

No one uses std::string in drivers as it throw exceptions. You need to use exception free STL (I saw that some guys use EASTL but I have no experience with it). Or you can write your own library.