AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi C++ Dll

Ein Thema von mandoza · begonnen am 27. Jan 2019 · letzter Beitrag vom 28. Jan 2019
Antwort Antwort
Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.782 Beiträge
 
Delphi 10.4 Sydney
 
#1

AW: Delphi C++ Dll

  Alt 28. Jan 2019, 07:11
Hi,

will it make a difference when using a packet record instead the unpacked one?

Delphi-Quellcode:
UserIdentity = packet record
    name_ : PAnsiChar;
    id : Integer;
  end;
Best regards
Klaus
Klaus
  Mit Zitat antworten Zitat
Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#2

AW: Delphi C++ Dll

  Alt 28. Jan 2019, 08:22
size_t is a plaform and architecture specific type ... using UInt32 might not be correct e.g. for 64-bit. The real problem is this part tho: GetMem(LUserEntity, pCount); It has to be GetMem(LUserEntity, pCount * SizeOf(UserEntity));
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)

Geändert von Zacherl (28. Jan 2019 um 08:26 Uhr)
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#3

AW: Delphi C++ Dll

  Alt 28. Jan 2019, 08:36
Why even multiply with `count`? The size of the struct is always the same. It only contains a pointer, not the characters themselves.
  Mit Zitat antworten Zitat
Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#4

AW: Delphi C++ Dll

  Alt 28. Jan 2019, 08:48
Why even multiply with `count`? The size of the struct is always the same. It only contains a pointer, not the characters themselves.
Nope. It fills the memory described by the pointer with the list elements. In C/C++ int* is basically the same as int[] . The struct size is ofc. the same, but the number of elements in the array might be different each time, so you have to alloc enough space to prevent buffer overrides (thats what happening without the *count).
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#5

AW: Delphi C++ Dll

  Alt 28. Jan 2019, 09:19
My bad, I did not read properly. I thought "count" was referring to the number of characters in the string, not the number of structs returned.
  Mit Zitat antworten Zitat
mandoza

Registriert seit: 27. Apr 2018
16 Beiträge
 
#6

AW: Delphi C++ Dll

  Alt 28. Jan 2019, 10:28
size_t is a plaform and architecture specific type ... using UInt32 might not be correct e.g. for 64-bit. The real problem is this part tho: GetMem(LUserEntity, pCount); It has to be GetMem(LUserEntity, pCount * SizeOf(UserEntity));
Thank you Zacherl , I've fixed the issue by using string fixed length in both C++ and Delphi , and using the UIntPtr instead of UInt32

Again thank you .
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:39 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz