开发者

invalid cruntime parameter _itoa_s

开发者 https://www.devze.com 2023-01-11 12:07 出处:网络
I have experienced a strange behavior when using _itoa_s and _ultoa_s if I try to get a char开发者_如何学Python array from an DWORD. The function returns zero(success) and my application continues, bu

I have experienced a strange behavior when using _itoa_s and _ultoa_s if I try to get a char开发者_如何学Python array from an DWORD. The function returns zero(success) and my application continues, but I'm getting an exception window with error code 0xc0000417 (STATUS_INVALID_CRUNTIME_PARAMETER).

ULONG pid = ProcessHandleToId(hProcess);  
int size = getIntSize(pid);  
char *pidStr = new char[size+1];  
_ultoa_s(pid, pidStr, size+1, 10);  
//do sth with pidStr...
delete[] (pidStr);`   

ProcessHandleToId returns the PID (DWORD) for a given ProcessHandle.

getIntSize returns the number of numbers to the corresponding int/char array (5555 => 4).


Yes, the safe CRT functions will abort your program with status code 0xc0000417 when they detect a problem. However, they will do this immediately, the function will not return.

Which means that you are looking at the wrong source code for this problem. It isn't the _ultoa_s() call that's bombing your program. It's another function call, somewhere else in your code. I can't help you find it of course. But the debugger should give you a good idea, look at the call stack when it breaks.


I just compiled your code and it runs fine. The int to string conversion is correct. I assume you bump into security issues due to missing permission when trying to access process handles you don't own.

0

精彩评论

暂无评论...
验证码 换一张
取 消