> For the complete documentation index, see [llms.txt](https://malwaresourcecode.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malwaresourcecode.com/home/markdown/convertcharstringtoint-ntdll.md).

# ConvertCharStringToInt (NTDLL)

ConvertCharacterStringToIntegerUsingNtdllW is dependent on WCharStringToCharString

```cpp
typedef NTSTATUS(NTAPI* RTLCHARTOINTEGER)(PCHAR, ULONG, PULONG);

ULONG ConvertCharacterStringToIntegerUsingNtdllA(_In_ PCHAR InString)
{
	RTLCHARTOINTEGER RtlCharToInteger = NULL;
	HMODULE hModule = NULL;
	ULONG ConvertedString = ERROR_SUCCESS;

	hModule = GetModuleHandleW(L"ntdll.dll");
	if (hModule == NULL)
		return 0;

	RtlCharToInteger = (RTLCHARTOINTEGER)GetProcAddress(hModule, "RtlCharToInteger");
	if (!RtlCharToInteger)
		return 0;

	if (RtlCharToInteger(InString, 10, &ConvertedString) != STATUS_SUCCESS)
		return 0;

	return ConvertedString;
}

ULONG ConvertCharacterStringToIntegerUsingNtdllW(_In_ PWCHAR InString)
{
	RTLCHARTOINTEGER RtlCharToInteger = NULL;
	HMODULE hModule = NULL;
	ULONG ConvertedString = ERROR_SUCCESS;
	CHAR pBuffer[MAX_PATH] = { 0 };

	hModule = GetModuleHandleW(L"ntdll.dll");
	if (hModule == NULL)
		return 0;

	RtlCharToInteger = (RTLCHARTOINTEGER)GetProcAddress(hModule, "RtlCharToInteger");
	if (!RtlCharToInteger)
		return 0;

	WCharStringToCharString(pBuffer, InString, StringLengthW((PWCHAR)InString));

	if (RtlCharToInteger(pBuffer, 10, &ConvertedString) != STATUS_SUCCESS)
		return 0;

	return ConvertedString;
}
```
