S
S
sddvxd2018-06-26 22:00:50
C++ / C#
sddvxd, 2018-06-26 22:00:50

How to "trim" part of an LPCWSTR array?

Hello!
When I intercept the NtCreateFile function and get the file name from there, something like this comes out:
\??\C:\мой_файл.data
I compare this string, and if it matches, then copying the file is prohibited
Can you tell me how to remove the first 4 characters or please tell me some function to check the occurrence (data type const wchar_t*)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sddvxd, 2018-06-26
@sddvxd

Solved a problem:

wchar_t *subwstr(const wchar_t *str, size_t startPos, size_t len)
{
    wchar_t* temp = new wchar_t[wcslen(str)+100];
    wmemcpy(temp, str, 100);
    temp[startPos + len] = '\0';
    return temp + startPos;
}
const wchar_t* subw = subwstr((LPCWSTR)ObjectAttributes->ObjectName->Buffer, 4, wcslen((LPCWSTR)ObjectAttributes->ObjectName->Buffer));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question