Click here to Skip to main content
15,898,795 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralIMAGES TO MOVIE file Pin
Emiliano27-Mar-05 14:15
Emiliano27-Mar-05 14:15 
GeneralRe: IMAGES TO MOVIE file Pin
Christian Graus30-Mar-05 12:04
protectorChristian Graus30-Mar-05 12:04 
GeneralRe: IMAGES TO MOVIE file Pin
Emiliano30-Mar-05 12:40
Emiliano30-Mar-05 12:40 
GeneralRe: IMAGES TO MOVIE file Pin
Christian Graus30-Mar-05 12:47
protectorChristian Graus30-Mar-05 12:47 
QuestionUDP Socket sample code is needed??? Pin
Kimdave23-Mar-05 22:13
Kimdave23-Mar-05 22:13 
AnswerRe: UDP Socket sample code is needed??? Pin
eli1502197926-Mar-05 20:54
eli1502197926-Mar-05 20:54 
QuestionHow do you call COM from a C++ web service? Pin
Chris Disdero22-Mar-05 16:10
Chris Disdero22-Mar-05 16:10 
GeneralCorrupt output from WideCharToMultiByte. Pin
zen0n21-Mar-05 1:31
zen0n21-Mar-05 1:31 
Hi!

System specs:
Language: C++
Compiler: Borland C++ 5.6 for Win32
OS: Windows Xp
App type: Console based application

I'm coding a Process-Lister program, where I try to output the DLLpath, ImagePathname and other strings gathered from the PEB block of each process..
This is (roughly) done in the way:

1) Read the start address of the RTL_USER_PROCESS_PARAMETER (RUPB*) from the PEB block. (offset = 0x010).
2) Read the UNICODE_STRING (US*) structure from the RUPB block (offset = depending on which field, ex: DLLPath = 0x030).
3) Read the Wide-character-string (UNICODE_STRING:Buffer) from the US block, (offset = 0x04), with the length (UNICODE_STRING:Length) bytes.

After this, I convert the read wide-character-string to a multibyte-string using the function WideCharToMultiByte.
Then I output it to the console using printf("%s\t",string)

The result is a lot of gibberish and makes no sense, I have tried changing the CodePage Identifier several times to several different types..
And still the problem remains...
Can someone help me? Or explain why? Iv'e been stuck with this problem for days now... And It's really getting to me..
See code below..

The following code demonstrates how I try to get the text from the UNICODE_STRING structure in the memory.....

<<-----CODE
.
.
UNICODE_STRING buff;
DWORD read;
if(ReadProcessMemory(process, (void *) address, &buff, 8, &read) == 0)
return;
if(buff.Length == 0)
return;
int str_size = buff.Length;
wchar_t *wchar_str = new wchar_t[str_size];
if(ReadProcessMemory(process, (void *) (address+4), wchar_str, str_size, &read) == 0){
RAP_ERROR(read);
return;
}
unsigned int codePage = 28591 //IS0-8859-1
unsigned int flag = 0;
int needed_for_trans = WideCharToMultiByte(codePage,flag, (LPCWSTR) wchar_str,-1,NULL,0,NULL,NULL);
char *multi_str = (char *)malloc(needed_for_trans);
int transed_bytes = 0;
if( (transed_bytes = WideCharToMultiByte(codePage, flag, (LPCWSTR) wchar_str, -1, multi_str, needed_for_trans, NULL, NULL)) == 0)
RAP_ERROR(read);
cout << "#DATA:";
int s = printf("%s\t", multi_str);
cout << "S:" << s << "\t";
cout << "¤BYTE:" << "[" << read << " | " << transed_bytes << endl;
delete[] wchar_str;
free(multi_str);
.
.
<<----------------------------------------------------

There is the critical piece ....
Now,, I would be REALLY glad if someone would help me....
The output from the printf is real gibberish....
And I don't understand why??

Thanks/ Gianfranco Alongi


/zen
GeneralRe: Corrupt output from WideCharToMultiByte. Pin
zen0n21-Mar-05 20:23
zen0n21-Mar-05 20:23 
GeneralC++ Windows Socket Problem. Pin
Anonymous20-Mar-05 9:06
Anonymous20-Mar-05 9:06 
GeneralRe: C++ Windows Socket Problem. Pin
Christian Graus20-Mar-05 13:44
protectorChristian Graus20-Mar-05 13:44 
GeneralRe: C++ Windows Socket Problem. Pin
toxcct22-Mar-05 4:10
toxcct22-Mar-05 4:10 
Generalplllzzz help me out:producer- consumer program urgently needed Pin
pradeep reddy19-Mar-05 20:26
pradeep reddy19-Mar-05 20:26 
GeneralRe: plllzzz help me out:producer- consumer program urgently needed Pin
Christian Graus20-Mar-05 13:43
protectorChristian Graus20-Mar-05 13:43 
GeneralRe: plllzzz help me out:producer- consumer program urgently needed Pin
skonopa23-Mar-05 3:50
skonopa23-Mar-05 3:50 
GeneralRe: plllzzz help me out:producer- consumer program urgently needed Pin
Christian Graus23-Mar-05 11:12
protectorChristian Graus23-Mar-05 11:12 
QuestionControlling ActiveChild form from MDI Parent - How? Pin
Francis TA19-Mar-05 5:18
sussFrancis TA19-Mar-05 5:18 
GeneralMultiple DllImportAttribute Statements Problem Pin
Chikky17-Mar-05 12:21
Chikky17-Mar-05 12:21 
GeneralRe: Multiple DllImportAttribute Statements Problem Pin
Chikky24-Mar-05 11:43
Chikky24-Mar-05 11:43 
Generalclosing a form/dialog Pin
doneirik16-Mar-05 1:36
doneirik16-Mar-05 1:36 
GeneralRe: closing a form/dialog Pin
Christian Graus16-Mar-05 15:43
protectorChristian Graus16-Mar-05 15:43 
GeneralRe: closing a form/dialog Pin
Anonymous18-Mar-05 20:58
Anonymous18-Mar-05 20:58 
QuestionCan i write a Dialog Based Program on DLL Pin
popo8414-Mar-05 15:47
popo8414-Mar-05 15:47 
AnswerRe: Can i write a Dialog Based Program on DLL Pin
User 91483328-Mar-05 12:02
User 91483328-Mar-05 12:02 
Generalerror C2061: syntax error : identifier 'SocketChatClient' Pin
neo_coder14-Mar-05 10:35
neo_coder14-Mar-05 10:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.