Comments (7)
nah i'll just write a little C stub to take the buffer pointer. Although i like C++'s fanciness sometimes it's too much imo
from polyhook_2_0.
Ok, it's your project.
Most of the time though, it will be as fast if not faster than a quick implementation you write yourself. It's not like the above is complicated or fancy. The lambda could also be replaced by a (struct) functor.
The only drawback I see is that std::wstring_view
allocated memory for the two pointers to start and end.
And it also defeats the purpose of stating that this is a C++17 library IMO.
from polyhook_2_0.
I appreciate your interest, I'd use string view if it had a icompare, but it doesn't unfortunately. Since this is the case I'd rather make a utility that doesn't require the construction, because it doesn't benefit us and reduce complexity. I use lots of c++ 17 goodies elsewhere where this is the case.
I'm honestly shocked case insensitive wide string compares aren't standard, it's annoying as fuck
from polyhook_2_0.
Then how about creating a modified char_traits<>
type which compares case-insensitively.
More details here: https://stackoverflow.com/questions/11635/case-insensitive-string-comparison-in-c/2886589#2886589
Something like this:
// Derive from std::char_traits<wchar_t>.
struct ci_wchar_traits : public std::char_traits<wchar_t> {
static bool eq(wchar_t c1, wchar_t c2) { return towupper(c1) == towupper(c2); }
static bool ne(wchar_t c1, wchar_t c2) { return towupper(c1) != towupper(c2); }
static bool lt(wchar_t c1, wchar_t c2) { return towupper(c1) < towupper(c2); }
static int compare(const wchar_t* s1, const wchar_t* s2, size_t n) {
while (n-- != 0) {
if (toupper(*s1) < toupper(*s2)) return -1;
if (toupper(*s1) > toupper(*s2)) return 1;
++s1; ++s2;
}
return 0;
}
static const wchar_t* find(const wchar_t* s, int n, wchar_t a) {
while (n-- > 0 && towupper(*s) != towupper(a)) {
++s;
}
return s;
}
};
// Define type alias.
using ci_wstring_view = std::basic_string_view<wchar_t, ci_wchar_traits>;
// Use type alias.
if (ci_wstring_view const baseModuleName{dte->BaseDllName.Buffer, dte->BaseDllName.Length / sizeof(wchar_t)};
!moduleName.empty() && baseModuleName.compare(moduleName.data()) != 0)
continue;
from polyhook_2_0.
I quite like that solution. If you are interested in implementation I'd merge a PR? If not I can see when I get around to this 😊
from polyhook_2_0.
Sure, I can submit a PR.
But I am not sure where you want the char_trait to be located?
If you plan on using it somewhere else, then it would make sense to put it into a separate file (header).
from polyhook_2_0.
You can place this in Misc.hpp
from polyhook_2_0.
Related Issues (20)
- Crash on VFuncSwapHook/VTableSwapHook Constructor HOT 1
- A windows app that uses std::stringstream crashes when PolyHook_2.lib is included in the link. HOT 8
- MessageBoxW & EatHook
- Cannot compile polyhook on linux using cmake HOT 4
- VEH Hook function HOT 1
- Stack overflow in PLH::ErrorLog::log HOT 3
- fail on link when use vcpkg with x64-windows-static HOT 17
- Does x86Detour seem not to work for external DLL calls? HOT 6
- A question about how to hook into external libraries. HOT 1
- When I tried to hook some functions, it caused the program to crash HOT 4
- Link issue with x86-windows-static HOT 1
- Calling the original function fails after hooking the same function twice or more HOT 2
- Crashes when hooking e.g. QueryPerformanceCounter in x64 but works with x86 HOT 1
- Design issues with bool hook() and bool unHook() HOT 1
- Hooking function fails with "Warn: Couldn't decompile instructions at followed jmp" and "Error: Prologue jmp resolution failed" HOT 9
- Improper hooks when RSP instructions are in the prologue HOT 1
- Crash caused by unsafe read HOT 4
- Implement detour unit tests with emulator HOT 1
- Failed to create hook on SHGetSpecialFolderPathW HOT 4
- find_package(PolyHook_2) fails because polyhook_2-config.cmake is not found on MinGW on Linux HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polyhook_2_0.