hex editors and c++

Started by
15 comments, last by Malachi 22 years, 9 months ago
How can I use my hex editor(winhex)to show me the sourcecode for compiled C++ applications?
Advertisement
I don''t know what your trying to hack ... but the short answer is ... you can''t!

FIRST
a HEX EDITOR .. is exactly that ... it displays the contents of a file in HEX (hexidecimal) notation - and then it lets you edit those values and save the file again. There is absolutely NO connection between a hex editor and source code.

SECOND
a DISASSEMBLER can be used to convert a compiled file (com, exe, lib, obj, etc ...) into ASSEMBLY language ... ALL executable code can be viewed no matter what the creator wrote it in - but you CANNOT get back to the source code they used, not in C, not C++, not VB, not anything but assembly (some converter convert assembly to C .. but not the ORIGINAL C the author wrote) ... and even the assembly with be useless in general ... because the variable names, comments, stack organization, etc .. will be unknown to you ... it is NOT contained in the code.

THIRD
if YOU are the author of the code ... and compiling it ... then the closest thing to what you desire is to use a SOURCE LEVEL DEBUGGER ... which will usually be available with your compiler ... you compile in DEBUG MODE .. which means the executable code contains extra symbols and such which allow it to show you which lines of you C++ program you are at when you run it in debug mode ... you can execute each line or function and watch the effect on your variables and such.

people that crack things use either HEX EDITORS ... to replace data with different values which benifit them (beefed up stats in games or such) ... or DISSASEMBLERS to find the code they wish to circumvent and the change it ... but all of that require a level of talent and understanding BEYOND that of normal programming ... from your questions naivety I would guess you do not possess such expertise.
That question actually doesn''t make sense:
quote:
How can I use my hex editor(winhex)to show me the >sourcecode< for >compiled< C++ applications?


If it''s compiled it''s not sourcecode, and if it''s sourcecode it''s not compile. Think about it! And about what you are actually trying to get at....might be worth it.

Cheers
- Sleepwalker

Born to code! - or coded to be born? I still wonder...

- Sleepwalker
GGRR....What I am trying to achieve is getting back my sourcecode off my compiled exe. After my sourcecode was corrupted by a hard drive crash. Yeah I know you need disassemblers to get the code but I read somewhere on the interent people used hex editors to get sourcecodes out of exes aswell.
You might find this interesting.

Of course, decompilation is a sketchy process at best, and I wouldn''t exactly rely on it.

~~~~~~~~~~
Martee
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Sorry Malachi, as others have said, your compiled exe doesn''t contain source code. A disassembler can give you the assembly code (because assembly has a 1-to-1 relationship to machine code) but your actual code listings are gone forever. Martee''s link to a decompiler might help if you have a simple C program, but even in the best case, you''re not going to get your variable names, function names, or comments back.

If the analogy helps, trying to get source code from an executable is like trying to get a recipe by picking through your meal.

However, I will offer you some help which may or may not be of use: hit F9 in Winhex, and get the Disk Editor up. Pick your corrupted disk, which hopefully you have not done a lot with since then, and use the Find tool to search the entire disk for your variable names. If you''re lucky, you can pull the whole project off there. (As I did, once... 150 files from a dead hard disk... ouch.) If you''ve been writing to the disk though, some of it may have been overwritten. And note that some of your files may be fragmented. Good luck.
This is also not in direct answer to your question, but if you''ve got a crashed hard drive, there are companies which will retrieve data from wrecked disks. For example, the people at www.datarecoverygroup.com specialize in this sort of thing (as well as recovering evidence for both civil and criminal courts!)

Mind you, it''s very expensive and may set you back upwards of $1000, you only pay if you get the data back though. If they get your data back, they send it to you on a CD, a new hard disk or your old hard disk (if they can repair it).

Just let this be a lesson to make regular backups

War Worlds - A 3D Real-Time Strategy game in development.
I''m a normal programmer and I crack a protected library using MSVC''s dissassembler and hex editor... it really wasn''t all that hard either.
I''m a normal programmer and I cracked a protected library using MSVC''s dissassembler and hex editor... it really wasn''t all that hard either.
I''m a normal programmer and I cracked a static library using MSVC''s dissassembler and hex editor... it really wasn''t all that hard either.

This topic is closed to new replies.

Advertisement