The WideStringLengthFromMode function calculates the length of a null-terminated wide character string, based on the specified processor mode.
Syntax
SIZE_T WideStringLengthFromMode(
const WCHAR *String,
KPROCESSOR_MODE Mode
);
Parameters
String
[in] null로 끝나는 와이드 문자열에 대한 포인터입니다.
Mode
[in] 메모리 액세스가 수행되는 방법을 결정하는 프로세서 모드입니다. Mode can be one of the following values.
| Value | Meaning |
|---|---|
| KernelMode | String points to kernel-mode memory. 함수는 직접 문자열 길이 계산을 수행합니다. 자세한 내용은 비고를 참조하세요. |
| UserMode | String points to user-mode memory. The function raises an exception if String doesn't point to user-mode memory; otherwise it performs a safe string length calculation at the specified address. 자세한 내용은 비고를 참조하세요. |
Return value
이 함수는 종결 null 문자를 포함하지 않고 와이드 문자로 문자열의 길이를 반환합니다.
Remarks
이 함수는 메모리에서 null로 끝나는 와이드 문자열의 길이를 계산하는 안전한 액세스를 제공합니다. 동작은 지정된 프로세서 모드에 따라 달라집니다.
- When Mode is UserMode, the function ensures that the string address is a valid user-mode address and performs the operation safely for user-mode memory access.
- When Mode is KernelMode, the function operates directly on kernel-mode addresses.
When the mode is UserMode, the function includes validation to prevent kernel crashes when accessing potentially invalid user-mode pointers. When the mode is KernelMode, it operates on known-safe kernel addresses for optimal performance.
문자열 주소에 액세스할 수 없거나 지정된 모드에 대해 유효하지 않은 경우와 같이 작업이 실패할 경우 함수는 구조적 예외를 발생합니다.
이 함수는 최신 버전뿐만 아니라 모든 버전의 Windows에서 작동합니다. You need to consume the latest WDK to get the function declaration from the usermode_accessors.h header. You also need the library (umaccess.lib) from the latest WDK. 그러나 결과 드라이버는 이전 버전의 Windows에서 잘 실행됩니다.
Requirements
| Requirement | Value |
|---|---|
| 지원되는 최소 클라이언트 | See Remarks |
| Header | usermode_accessors.h |
| Library | umaccess.lib |
| IRQL | APC_LEVEL 작거나 같음 |