Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   C++ Inhalt eines String-Buffers char ** (https://www.delphipraxis.net/123360-inhalt-eines-string-buffers-char-%2A%2A.html)

napsterxx 31. Okt 2008 11:53


Inhalt eines String-Buffers char **
 
Also ich habe hier ein Code-Snippet:
Code:
void CExampleTcpPlugin::BeforeSendToRemote(UINT32 sessionId, UINT32 toUserId,
                            char ** ppData ,int * pDataLen, bool * pContinue)
{
   
   file<<"BeforeSendToRemote"<<seperator<<endl;
}
wie kann ich nun anstelle von seperator den Inhalt von ppData in die Datei schreiben? pDataLen ist 103 lang, jedoch habe ich nur mit **ppData den ersten char erhalten.

Andi1985 31. Okt 2008 12:48

Re: Inhalt eines String-Buffers char **
 
versuchs mal damit:

Code:
void CExampleTcpPlugin::BeforeSendToRemote(UINT32 sessionId, UINT32 toUserId,
                            char ** ppData ,int * pDataLen, bool * pContinue)
{
   
   file<<"BeforeSendToRemote"<<**(&ppData)<<endl;
}

napsterxx 31. Okt 2008 14:00

Re: Inhalt eines String-Buffers char **
 
Nein, geht immernoch nicht.

Andi1985 31. Okt 2008 14:05

Re: Inhalt eines String-Buffers char **
 
Zitat:

Zitat von napsterxx
Nein, geht immernoch nicht.

Folgendes Beispiel funktioniert bei mir recht gut, vieleicht bringt dich das weiter, ansonsten wüst ich jetzt auch keine Lösung.

Code:
#include <iostream>

using namespace std;

void test(char **ppData) {
   cout << **(&ppData) << endl;
}

int main() {
   
   char buff[] = "Hallo Welt";
   char *pBuff = &buff[0];

   test(&pBuff);

   system("PAUSE");
}
b.z.w. mit Stream schreiben:

Code:
void test(char **ppData) {
   fstream file("test.txt", ios::out);
   file << **(&ppData);
   file.close();
}

napsterxx 31. Okt 2008 14:44

Re: Inhalt eines String-Buffers char **
 
Bei dem Inhalt handelt es sich um ein UDP Paket. Das Problem ist, ich weis wie lang es sein muss aber bekomme auch bei deiner Methode nur 3 Zeichen angezeigt.

napsterxx 1. Nov 2008 18:03

Re: Inhalt eines String-Buffers char **
 
Glaube das liegt an was anderem, das der String vll 0-terminiert ist oder so?


Delphi-Quellcode:
   file<< "0: " <<**(&ppData)<<endl;
   file<< "1: " <<*(&ppData)<<endl;
   file<< "2: " <<(&ppData)<<endl;
   file<< "3: " <<**(ppData)<<endl;
   file<< "4: " <<*(ppData)<<endl;
   file<< "5: " <<**(&ppData)[0]<<endl;
   file<< "6: " <<*(&ppData)[0]<<endl;
   file<< "7: " <<(&ppData)[0]<<endl;
   file<< "8 " <<(ppData)[0]<<endl;
4, 6, 8 liefern jeweils den selben Wert
5, 3, 0 liefern jeweils den selben Wert
1, 2, 7 sind Adressen

Bleiben 2 Version: 0 und 4

Davon ist meiner Meinung nach aber nur Version 4 relevant, aber ich bekomme hier nur 3 Zeichen angezeigt, mehr als bei allen anderen, aber trotzdme viel zu wenig.

CorVu5 3. Nov 2008 19:39

Re: Inhalt eines String-Buffers char **
 
Es ist ja sehr wahrscheinlich, dass im Paket mal OOh vorkommt. Genaugenommen ist es sogar immer so, wenn ich mich nicht irre.
Du solltest zuerst den String in Hex umwandeln und dann anzeigen, bzw. nicht darstellbare Zeichen in "." oder so umwandeln.


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:35 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz