|
mutafa81 wrote: is there is any way to get the code from EXE
Yes - you can disassemble the code.
mutafa81 wrote: and how to protect my EXE from this
You might want to try an obfuscator. It won't stop you getting the cod out, but it will make it bloody hard to read.
|
|
|
|
|
Pete O'Hanlon wrote: You might want to try an obfuscator. It won't stop you getting the cod out, but it will make it bloody hard to read.
I agree. Though I know of an obfuscator that can cause Reflector to crash when trying to disassemble the obfuscated code.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
That sort of thing isn't worth worrying about.
|
|
|
|
|
Nah, I don't agree.
While this might be true for most apps, it's surely not for all of them. It entirely depends upon what's inside your code (e.g. company-specific algorithms that are protected by law).
At least you have to know about the problem to be able to make an informed decision about it.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
PIEBALDconsult wrote: That sort of thing isn't worth worrying about
Not if you have intellectual property that you do not want the competition to find, or a client to have some one dig around in your work and sell it to someone else.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
The big question is, why would someone want to read your code ? People who worry about that, usually have nothing to worry about.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: why would someone want to read your code ?
Spying among competing businesses could be one reason.
While most of the programs written won't need protection indeed, there might be some that do. It's in any way a good thing to know about the problem and its possible 'solutions'.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Perhaps, but in most cases, it's not needed. In fact, I've seen people who have ASP.NET sites ask this ( how does anyone get the dlls in that case ? )
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: Perhaps, but in most cases, it's not needed.
I fully agree.
Christian Graus wrote: I've seen people who have ASP.NET sites ask this
This obviously doesn't make any sense at all.
These things happen when people do not know (or care) how it all works.
I just wanted to say: You have to be aware that there can be an issue.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
mutafa81 wrote: is there is any way to get the code from EXE
Yes, this is easily done. The best and most popular tool for that is .NET Reflector[^].
mutafa81 wrote: and how to protect my EXE from this
There is no real escape. What you can do is use an obfuscator. These tools don't protect your code from being disassembled, but they make it as unreadable as possible.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Thomas Weller wrote: These tools don't protect your code from being disassembled, but they make it as unreadable as possible.
While that is true, I did find one such obfuscator that actually crashes Reflector. The obfuscator was relatively inexpensive compared to some of the others out there.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
You could always use .NET Reactor, it merges the application with native code.
It stops any decompiling according to the website.
A craft is an enemy if not well learned.
|
|
|
|
|
Hi everyone,
I created an application which simply create a rectangle on a PictureBox, here's the code:
void DrawRectangle(IntPtr hWnd)
{
Rectangle rectSquare;
GraphicsPath graphPath;
PathGradientBrush brushSquare;
Graphics gameGraphics;
gameGraphics = Graphics.FromHwnd(WinHandle);
graphPath = new GraphicsPath();
rectSquare = new Rectangle(100, 100, 100, 100);
graphPath.AddRectangle(rectSquare);
brushSquare = new PathGradientBrush(graphPath);
brushSquare.CenterColor = Color.Red;
brushSquare.SurroundColors = new Color[] { Color.Blue };
gameGraphics.FillPath(brushSquare, graphPath);
}
Also I have a button:
private void button1_Click(object sender, EventArgs e)
{
DrawRectangle(pictureBox1.Handle);
}
They're working fine but when I minimize my Form and then restore, the rectangle would disappear!
I tried calling DrawRectangle in pictureBox1 Paint event but nothing changed.
How can I redraw my rectangle?
Thanks.
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
Hi,
1.
yes all painting should be performed in Paint handlers; one of the reasons is exactly the problem you encounter: it is the Paint handlers that will get fired by Windows when ever there is reason to repaint (part of) a Control (a Form is a Control); restoring from Minimized is a very good reason to repaint everything.
2.
Graphics.FromHwnd() creates a NEW Graphics, which you must Dispose() off when you are done. It is a slow and costly operation that can be avoided.
3.
Why take the long route of taking a handle, asking for a new Graphics, then drawing; all you have to do is set up some data fields that describe the rectangle you want, then Invalidate() the Control (in your case PictureBox), so its Paint handler gets executed again (and draws a rectangle according to the relevant data fields). The Graphics you find in the PaintEventArgs is free, it is not expensive, and you SHOULD NOT Dispose() of that one, since you did not cause its creation, so it isn't your Graphics object.
|
|
|
|
|
4.
The graphics object that you get in the Paint event is clipped to the screen area that you may draw on. This keeps you from drawing on top of other windows when your window is partially covered.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi guys,
Sorry I'm late, I had a busy day.
I got it, thank both of you a lot. I just put all of my code in Pain event and that's work
Just another question:
I want to draw my rectangle by a button in my form, I thought about this kind of code:
void pictureBox_Pain(object sender, PainEventArgs e)
{
if(sender is Button)
{
}
}
Am I right? Or there's another (faster, better,...) way?
Thanks
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
No, that is not the correct way.
If you want to draw something on a control, that is done in two steps:
1. Store information about what to draw in some variable(s) in the form. Call the Invalidate method on the control that you are drawing on.
2. In the Paint event for the control you use the information that you stored to do the actual drawing.
Example:
private bool _showRectangle = false;
void someButton_Click(object sender, EventArgs e) {
_showRectangle = true;
pictureBox.Invalidate();
}
void picturebox_Paint(object sender, PaintEventArgs e) {
if (_showRectangle) {
e.Graphics.DrawRectangle(Pens.Black,10,10,10,10);
}
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks friend,
Helped me a lot
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
Evening all !
I'm working on my first ever uni assignment in c# and would like to smarten up the application a bit.
Can anyone point me in the direction of a good site/tutorial etc for implemnting some graphics ?
I have a few main form, some panels etc - do i just assign pictures to them the same way as i have done for a picture box ?
Also, is there any way of changing a panel so it's not just a square/rectangle shape ?
Many thanks
Neil
|
|
|
|
|
What do you mean by 'implimenting some graphics' ? If you have bitmaps you can skin buttons with them or draw them on your form if you're just looking to improve the way it looks.
To draw a picture on the background of a form, handle it's OnPaint event, this is passed a graphics object and you can draw your bitmap to that.
You can search the web for ways to make forms an irregular shape, there's almost certainly example projects here on Code Project.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
I am the new about class and objects in c#. I just want to define an object for this issue after than I will save and restore from a file this ExamFile.
ExamFile.Title = "Test Exam File";
ExamFile.FileName = "my First Exam.mfe";
ExamFile.Exam[0].ExamName = "This is my First Exam";
ExamFile.Exam[1].ExamName = "This is my Second Exam";
ExamFile.Exam[0].Question[0].Remark = "First Exam's first Q";
ExamFile.Exam[0].Question[0].Type = "Multiple";
ExamFile.Exam[0].Question[1].Remark = "First Exam's Second Q"
ExamFile.Exam[0].Question[1].Type = "Single";
ExamFile.Exam[1].Question[0].Remark = "Second Exam's First Q";
ExamFile.Exam[1].Question[0].Type = "Multiple";
Thanks
|
|
|
|
|
Something like..
public class ExamFileBase
{
public string Title { get; set; }
public string FileName { get; set; }
public List<exambase> Exam { get; set; };
public ExamFileBase()
{
Title = "Default title";
FileName = "default_filename.mfe";
Exam = new List<exambase>();
}
}
public class ExamBase
{
public string ExamName { get; set; }
public List<questionbase> Question { get; set; }
public ExamBase()
{
ExamName = "Default exam";
Question = new List<questionbase>();
}
}
public class QuestionBase
{
public string Remark { get; set; }
public string Type { get; set; }
}
</questionbase></questionbase></exambase></exambase>
Only problem is, for the List<t> properties, you'd have to initiate a class before accessing it.
IE:
ExamFileBase ExamFile = new ExamFileBase();
ExamFile.Exam.Add(new ExamBase());
Unless you made them static so each was initialized auto-matically.
|
|
|
|
|
From your code it's evident that you want ExamFile to be a collection of Exam objects. Exams have names and a collection of Question(s), and Question has two string attributes, Remark and Type.
This object model is easily expressed in C#:
public class ExamFile
{
public string Title { get; set; }
public string Name { get; set; }
readonly public List<exam> Exams = new List<exam>();
}
public class Exam : List<question>
{
public string Name { get; set; }
readonly public List<question> Questions = new List<question>();
}
public class Question
{
public string Remark { get; set; }
public string Type { get; set; }
}
</question></question></question></exam></exam>
You could construct the object graph and then set properties as in your posted code, like this:
ExamFile file = new ExamFile();
file.Add(new Exam());
file.Add(new Exam());
file.Exams[0].Questions.Add(new Question());
file.Exams[0].Questions.Add(new Question());
file.Exams[1].Questions.Add(new Question());
file.Exams[1].Questions.Add(new Question());
and then do as in your posted code
file.Title = "Test";
...
file.Exams[1].Questions[1].Remark = "tough question";
However, in most cases you'd create a question object and set it's properties before adding it to an exam. Also note that the types themselves should usually have constructors that take some parameters. This has two side-effects: Less code to write to use the type, which is not very important but a marginal benefit, and a guarantee that an instance of a type cannot be created without certain minimum information.
Types should typically be designed to be flexible and general. Coding convenience can be achieved by writing little "helper methods" separately from the type itself. In this case, you could do something like this:
void addQuestion(Exam e, string remark, string type)
{
Question q = new Question();
q.Remark = remark;
q.Type = type;
e.Questions.Add(q);
}
Exam addExam(ExamFile f, string name)
{
Exam e = new Exam();
e.Name = name;
f.Exams.Add(e);
return e;
}
ExamFile file = new ExamFile();
f.Title = "test";
f.Name = "my first exam.mfe";
Exam e = addExam(file, "First Exam");
addQuestion(e, "remark #1", "Mutiple");
addQuestion(e, "remark #2", "I don't know");
and so on.
|
|
|
|
|
Hello,
You question is very large. I will try to answer you with a simple and short answer, and if you feel you need more explanations, feel free to post back here.
You will need more than a single object to hold your information. For instance, you could use a ExamFile, Exam and Question objects. In the ExamFile object, you could have a List<exam>, and in Exam object you could have a List<question>.
Here is a concrete example of a data structure to hold your information :
using System;
using System.Collections.Generic;
public class ExamFile
{
public String Title { get; set; }
public String FileName { get; set; }
public List<exam> Exams { get; set; }
}
public class Exam
{
public String ExamName { get; set; }
public List<question> Questions { get; set; }
}
public class Question
{
public String Remark { get; set; }
public String Type { get; set; }
}</question></exam>
|
|
|
|