| Autor |
Nachricht |
randydom
Hält's aus hier
Beiträge: 8
|
Verfasst: Sa 07.01.12 15:03
Could someone helps me in porting this C++ function into Delphi?
sys is a class named TSystem.
SharedMem is a class named TVirtualMemory
|
| |
|
|
Werbung ausblenden? Dann registriere Dich kostenlos.
Weitere Gründe für eine Registrierung.
Werbung ausblenden? Dann registriere Dich kostenlos.
Weitere Gründe für eine Registrierung.
|
|
Delphi-Laie
       
Beiträge: 501
Erhaltene Danke: 29
Delphi 2-4
|
Verfasst: Sa 07.01.12 16:14
Wie wäre es denn auf Deutsch? Schließlich ist das hier ein deutschsprachiges Forum!
|
| |
|
|
jaenicke
      
Beiträge: 15833
Erhaltene Danke: 737
XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
|
Verfasst: Sa 07.01.12 18:29
Für diesen Beitrag haben gedankt: Dude566
|
| |
|
|
randydom 
Hält's aus hier
Beiträge: 8
|
Verfasst: Sa 07.01.12 18:41
sorry Delphi-Laie because i don't speak German ( sorry again ).
thank you jaenicke .
i did this attempt :
| Zitat: | | Without the context I don't see what the code is supposed to do exactly |
The code is stripped from a machine emulator.
many thanks
|
| |
|
|
Delphi-Laie
       
Beiträge: 501
Erhaltene Danke: 29
Delphi 2-4
|
Verfasst: Sa 07.01.12 18:42
Dann sollte man aber wenigstens sich kurz dazu äußern, warum man zu der Gastfreundlichkeit, sich in der Sprache des Gastgebers äußern zu können, nicht imstande ist. Soviel Anstand sollte schon sein.
Übrigens, Ankunftsgruß, Bitte und Danke gibt es auch im Englischen, was ich oben auch vermisse.
Ich verstehe Englisch durchaus, werde aber einen Teufel tun, mich auch noch innerhalb meines Sprachraumes in eine Fremdsprache verbiegen zu lassen.
|
| |
|
|
jaenicke
      
Beiträge: 15833
Erhaltene Danke: 737
XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
|
Verfasst: Sa 07.01.12 19:08
Well, in Delphi you don't have the possibility to use the pointer "names" as an array implicitly. The easiest way is just to increase the pointer after each loop. This way you just jump to the next entry and that's all you need.
If you do so you can just use names^ instead of names[i]. Then we have this expression: names[i]->name+FileHandler
What is done in C++ is: take the first character of name as ordinal value ans add it to FileHandler. So in Delphi (dependend on your definition of image_import_by_name use the first index for the name array, 0 or 1):
The bitwise and operator & in C++ is in Delphi just and. You can compare the result against 0 as you want to know whether the expression is false in C++ and false is 0.
This should be all I think. 
|
| |
|
|
Christian S.
       

Beiträge: 18451
Erhaltene Danke: 641
Win 7
C# (VS 2010)
|
Verfasst: Sa 07.01.12 19:22
Delphi-Laie hat folgendes geschrieben : | | Ich verstehe Englisch durchaus, werde aber einen Teufel tun, mich auch noch innerhalb meines Sprachraumes in eine Fremdsprache verbiegen zu lassen. |
Es zwingt Dich niemand, auf Englisch zu schreiben.
In diesem Forum sind englischsprachige User ausdrücklich willkommen. Wenn Du mit solchen Postings nicht klar kommst, ignoriere sie bitte einfach. Eine Diskussion darüber ist in diesem Thread fehl am Platze, ich bitte daher drum, beim Thema zu bleiben.
@randydom: Feel free to continue posting in english. That's absolutely no problem for us! 
_________________ Physics is a bitch.
Für diesen Beitrag haben gedankt: Dude566, glotzer, jaenicke, Mitmischer 1703, Narses, Oliver Marx, platzwart, Xion
|
| |
|
|
randydom 
Hält's aus hier
Beiträge: 8
|
Verfasst: Sa 07.01.12 19:31
thank you jaenicke ;
and this how can i read it , because normally its result is a boolean value .
@Christian S : thank you .
@Delphi-Laie : again i'm really sorry .
|
| |
|
|
jaenicke
      
Beiträge: 15833
Erhaltene Danke: 737
XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
|
Verfasst: Sa 07.01.12 20:03
randydom hat folgendes geschrieben : | and this how can i read it , because normally its result is a boolean value .
|
As I said / meant  // EDIT:
And again: Use 0 or 1 as index according to your definition of name.
|
| |
|
|
Martok
      

Beiträge: 2836
Erhaltene Danke: 182
Win 2000, Win XP
Delphi 7, Turbo Delphi Exp.
|
Verfasst: Sa 07.01.12 20:16
jaenicke hat folgendes geschrieben : | As I said / meant  |
Are you sure this (using Ord) would actually compile? Coincidentally, I tried the exact same thing yesterday and it did not: I had to use a cast to an actual type (in this case DWORD or Cardinal {which are the same}) for it to work.
_________________ "The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Ich code EdgeMonkey -~==~- #ee-lounge in Freenode
|
| |
|
|
jaenicke
      
Beiträge: 15833
Erhaltene Danke: 737
XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
|
Verfasst: Sa 07.01.12 20:27
Yes, I am absolutely sure. 
|
| |
|
|
mandras
      
Beiträge: 90
Erhaltene Danke: 9
D6 Prof, XE2 Prof
|
Verfasst: So 08.01.12 11:44
does the following:
take entry [i] of names, then there look in "field" name at the 4 bytes at position <filehandler>,
use them as DWORD (32Bit-integer) and test if highest bit is set.
|
| |
|
|
randydom 
Hält's aus hier
Beiträge: 8
|
Verfasst: Di 10.01.12 14:40
many thanks for you all , but i still need some little help with this :
i did this in Delphi :
What about this :
|
| |
|
|
jaenicke
      
Beiträge: 15833
Erhaltene Danke: 737
XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
|
Verfasst: Di 10.01.12 15:03
You have to call Exit in addition to setting result to zero, 'cause in Delphi you do not exit the function when assigning the result.
In newer versions of Delphi you can just write Exit(0); instead of result := 0;. Before about Delphi 2009 you have to assign 0 to result and call Exit afterwards.
|
| |
|
|
randydom 
Hält's aus hier
Beiträge: 8
|
Verfasst: Di 10.01.12 15:16
jaenicke wrote : | You have to call Exit in addition to setting result to zero, 'cause in Delphi you do not exit the function when assigning the result.
In newer versions of Delphi you can just write Exit(0); instead of result := 0;. Before about Delphi 2009 you have to assign 0 to result and call Exit afterwards. |
@ jaenicke thank you for this valuable information .
just a help about this :
|
| |
|
|
jaenicke
      
Beiträge: 15833
Erhaltene Danke: 737
XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
|
Verfasst: Di 10.01.12 15:37
randydom hat folgendes geschrieben : | just a help about this :
|
Your code looked quite good. I thought you just had to correct the translation of return.
If it does not work, what does happen?
|
| |
|
|
randydom 
Hält's aus hier
Beiträge: 8
|
Verfasst: Di 10.01.12 15:51
Ok jaenicke look at this
i get an exception near :
i think the problem is when assigning FileHandler(FileHandler=dword) to pDos_header and the result is PEHeaderPtr(PEHeaderPtr=dword).
Or if possible can you re-convert this code :
|
| |
|
|