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??

Recommended Answers

All 3 Replies

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.