Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

C++ question

Thread Tools
 
Search this Thread
 
Old 27 February 2003, 12:51 PM
  #1  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

Does
mptr++^=0x96969696 (C++)
=
mptr=mptr + (mptr XOR &H96969696) (VB)

?
help appreciated.
Old 27 February 2003, 01:02 PM
  #2  
super_si
Scooby Regular
 
super_si's Avatar
 
Join Date: Feb 2002
Location: Lurkin Somewhere
Posts: 7,951
Likes: 0
Received 0 Likes on 0 Posts
Post

Where's Marko when you actually need him
Old 27 February 2003, 01:14 PM
  #3  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

I think it's right, I just need someone to say.

I've found some C++ code to extract VSS passwords - just translating it to VB.
Old 27 February 2003, 02:34 PM
  #4  
dharbige
Scooby Regular
 
dharbige's Avatar
 
Join Date: Feb 2001
Posts: 845
Likes: 0
Received 0 Likes on 0 Posts
Post

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.

Old 27 February 2003, 03:53 PM
  #5  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

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!!

Old 27 February 2003, 04:39 PM
  #6  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Post

I bet you can knock up a cutesy little furry animal to guide a newbie through the opening of a file in 1 line of VB though
Old 27 February 2003, 04:53 PM
  #7  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 27 February 2003, 05:02 PM
  #8  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Post

I don't think I'd have the patience to type all that to open a file
Old 27 February 2003, 05:05 PM
  #9  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Post

nor would I,

just do-

AStringList := TStringList.Create;
AStringList.LoadFromFile('C:\autoexec.bat');

Sorted!

Gary
Old 27 February 2003, 05:08 PM
  #10  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Post

Looks like you're using a library, that would be cheating
Old 27 February 2003, 05:11 PM
  #11  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Post

Nah,

using Delphi not VB!!!
Old 27 February 2003, 05:13 PM
  #12  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Post

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
Old 27 February 2003, 11:24 PM
  #13  
IWatkins
Scooby Regular
 
IWatkins's Avatar
 
Join Date: Mar 2000
Location: Gloucestershire, home of the lawnmower.
Posts: 4,531
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 28 February 2003, 09:46 AM
  #14  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
slimwiltaz
General Technical
20
09 October 2015 07:40 PM
IanG1983
Wheels, Tyres & Brakes
2
06 October 2015 03:08 PM
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM
the shreksta
Other Marques
26
01 October 2015 02:30 PM



Quick Reply: C++ question



All times are GMT +1. The time now is 11:01 AM.