C++ question
#4
I don't think you're quite right. The "++" would just add 1 (albeit after the XOR):
mptr = (mptr XOR &H96969696) + 1
But are you sure you've got the original code correct?
The code as it stands would not compile in c++, as the mptr++ evaluates to a "real" value, not a variable, so it cannot then have a value assigned to it.
What seems more likely is
*(mptr++) ^= 0x96969696
...which would XOR the value pointed to by mptr with the constant value, then increment the pointer onto the 'next' value.
The is a bit more complex in VB, as VB does not use pointers, and so you would have to write the code quite differently.
David H.
mptr = (mptr XOR &H96969696) + 1
But are you sure you've got the original code correct?
The code as it stands would not compile in c++, as the mptr++ evaluates to a "real" value, not a variable, so it cannot then have a value assigned to it.
What seems more likely is
*(mptr++) ^= 0x96969696
...which would XOR the value pointed to by mptr with the constant value, then increment the pointer onto the 'next' value.
The is a bit more complex in VB, as VB does not use pointers, and so you would have to write the code quite differently.
David H.
#5
Scooby Regular
Thread Starter
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes
on
0 Posts
Ahh, I see! cheers.
I've already had to write a << >> equivalent
Function BitShift(lIn As Long, bLeft As Boolean, lBits As Long) As Long
BitShift = (lIn * IIf(bLeft, 2, 0.5)) And ((2 ^ lBits) - 1)
End Function
3 lines of code to replace 2 characters!!
I've already had to write a << >> equivalent
Function BitShift(lIn As Long, bLeft As Boolean, lBits As Long) As Long
BitShift = (lIn * IIf(bLeft, 2, 0.5)) And ((2 ^ lBits) - 1)
End Function
3 lines of code to replace 2 characters!!
#7
Scooby Regular
Thread Starter
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes
on
0 Posts
StringVariable = FileText("c:\autoexec.bat")
Function FileText(ByVal filename As String) As String
Dim handle As Integer
If Len(Dir$(filename)) = 0 Then Err.Raise 53
handle = FreeFile
Open filename$ For Binary As #handle
FileText = Space$(LOF(handle))
Get #handle, , FileText
Close #handle
End Function
1 line... ish
Function FileText(ByVal filename As String) As String
Dim handle As Integer
If Len(Dir$(filename)) = 0 Then Err.Raise 53
handle = FreeFile
Open filename$ For Binary As #handle
FileText = Space$(LOF(handle))
Get #handle, , FileText
Close #handle
End Function
1 line... ish
Trending Topics
#12
Scooby Regular
I can tell that from the variable assignments, having a function to load from a file is quite high level. Verbosity is what puts me off learning Java, Perl has made me way too lazy
#13
Scooby Regular
Join Date: Mar 2000
Location: Gloucestershire, home of the lawnmower.
Posts: 4,531
Likes: 0
Received 0 Likes
on
0 Posts
Hey Gary, don't forget to .Free it afterwards
(From someone who has been chasing an exception in a Delphi ISAPI DLL all day)
Cheers
Ian
(From someone who has been chasing an exception in a Delphi ISAPI DLL all day)
Cheers
Ian
#14
Scooby Regular
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes
on
0 Posts
Ian,
I use Sleuth QA Suite for all my debugging/testing/mem. checking and its awesome. What you may not know is Turbopower who sell the tool are putting *all* their software out as GPL lots of cool stuff you had to pay for is now free! Just do a search for Turbopower on sourceforge.net !
Cheers
Gary
I use Sleuth QA Suite for all my debugging/testing/mem. checking and its awesome. What you may not know is Turbopower who sell the tool are putting *all* their software out as GPL lots of cool stuff you had to pay for is now free! Just do a search for Turbopower on sourceforge.net !
Cheers
Gary
Thread
Thread Starter
Forum
Replies
Last Post
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM