0

WriteProcessMemory(processHandle, address, name.c_str(),sizeof(name.c_str()),NULL)
|
|
is this third argument valid for this function? if not how would i make my std::string return the start address of a c string??

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Narue
0

The third argument is valid (it's just a c-style string), but the fourth argument is incorrect. name.size() or name.size()+1 is likely what you intended.

0

oh ok thats good...im trying to figure out the reason for my program crashing! how come when i view my std::wstring in the debugger, i dont see the appended null at the end??? where is the null sentinal at the end of this string? could this be why my program is crashing? or are all strings like this?

- Name "fileOPP.exe" std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >
 [size] 11 unsigned int
 [capacity] 15 unsigned int
  [0] 109 L'f' wchar_t
  [1] 115 L'i' wchar_t
  [2] 110 L'l' wchar_t
  [3] 109 L'e' wchar_t
  [4] 115 L'O' wchar_t
  [5] 103 L'O' wchar_t
  [6] 114 L'P' wchar_t
 [7] 46 L'.' wchar_t
 [8] 101 L'e' wchar_t
 [9] 120 L'x' wchar_t
 [10] 101 L'e' wchar_t
0

The actual storage in a string object need not include a null character at the end. In cases where it's not maintained internally, the c_str member function will add one.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.