|
If there is only one if statement that does the check, it really doesn't matter whether you use system registry, usb dongle or computer hash. Every application written in .Net can be easily decompiled and it only takes putting ! in the if statement to make an application work on every computer. Obfuscators make it more difficult but not very much. Even application written in native c++ or vb can be easily cracked. In case it's assembler that does the cracking.
The fact that general users will not be able to make necessary registry manipulation does not mean anything as usually it's crackers you crack the program and not users. Users just download them from warez websites. Crackers on the other hand have much more knowledge than general users and use advanced tools for cracking.
What I suggest is that you put checks at different places in the program and not so obvious. Having a dll called license.dll will attract crackers. On the other hand you can put some code in license.dll which looks like license check but does nothing in reality.
Good luck!
P.S. Remember that it is very difficult to make an application that can not be cracked. The only thing you can and should do is make more difficult your program to crack and put reasonable price on it so that it really does not make sense to crack it.
|
|
|
|
|
I am having problem to delete a Managed C++ DLL that was used in a
pure C# DLL even in the following scenario.
1. Launch the application. This applicatio has its own default
applicaiton domain.
2. Create a new Application Domain.
3. Load the Pure C# DLL in the new applicaiton domain. This C# DLL uses
managed C++ DLL.
4. Create a Proxy object using CreateInstanceAndUnwrap for the wrapper
object which is a wrapper for the class used from the pure C# DLL.
This wrapper object is exported from a seperate DLL.
DLL Configuration:- Wrapper for C# DLL, C# DLL, Managed C++ DLL.
The wrapper C# is used so that the main C# will not be loaded into
the default application domain when creating a Proxy object using the
menthod CreateInstanceAndUnwrap. The application domain talks with
only the wrapper DLL. If we do not have wrapper class, then the main
C# DLL will also be loaded into the default application. The sideeffect
of this is that, even when the new application is unloaded, we will not
be able to delete the main C# DLL. Wrapper is just a call frowader to
the C# DLL class.
5. Give the class name exported from C# DLL to the wrapper object and ask
it to create an instance of the class. The wrapper class creates the
the class and initializes its membet to it, so that it can forward
call requests.
6. From the default application domain, call a method on the wrapper object.
This call on the wrapper object calls the method on the C# class. This
C# class uses a function exported from a managed C++ DLL.
7. After executing the methods, unload the new application domain.
8. Now try to delete C# DLL, Mananged C++ DLL.
I was able to delete C# DLL, but not MC++ DLL. After further investigation
I found that the Visual Studio "Output" window has the following two lines:-
'Application.exe': Loaded 'C:\DLL1\Debug\MCPP.dll', Symbols loaded.----> LOADING FIRST TIME
'Application.exe' (Managed): Loaded 'C:\DLL1\Debug\MCPP.dll', Symbols loaded. ----> LOADING SECOND TIME
When the method on C# class is getting executed, the output log file
contains the above two lines. The .NET framework is loading it twice.
Once as Native C++ DLL, second time as Managed DLL.
Does any one know how to delete the MC++ DLL.
|
|
|
|
|
chandrap wrote: 3. Load the Pure C# DLL in the new applicaiton domain. This C# DLL uses
managed C++ DLL.
Where is this done from? Shouldn't the wrapper be doing this in the
new appdomain?
chandrap wrote: I was able to delete C# DLL,
It seems to me you shouldn't be able to do that. I'm missing something.
Isn't the C# DLL loaded in both appdomains (in steps 3 and 5)?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes you are correct, the Step3 is done in in the new application domain. Not in the default domain. Step5 uses the Step3 loaded assembly reference in the new appDOmain, to create the C# object.
Since the C# DLL is only loaded in the new application domain, I was able to delete it.
|
|
|
|
|
Hi
After further investigation I found out that the default application domain is also loading the MC++ DLL even though I do not use it anywhere in the default application domain. The only place I use MC++ DLL is in the C#. The C# DLL gets unloaded when I unload the new application domain since it was loaded only in the new application domain. Why is the MC++ DLL getting loaded both in default and new application domain.
Thanks
Chandra
|
|
|
|
|
Thanks
Why do you do step 3, and how do you do it?
It seems to me, the wrapper should be doing step 3, but you don't have a
wrapper until step 5.
What I'm getting at here, is an early binding to the C++ DLL, possibly caused by
step 3, where the C++ DLL is getting inadvertently loaded in both domains...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you for your reply.
I create Assembly Manager class inside the new application domain
appDomain->CreateInstanceAndUnwrap("Wrapper.dll", "AssemblyMgr")
Then ask the wrapper DLL to load.
After this step we create the class in step 5 using the following code.
Type testClassType = assembly.GetType(className);
CSharpClass = (CSharpClass)Activator.
CreateInstance(testClassType);
Step3 is done to have the assembly loaded once, step 5 is used to create different classes from the same assembly. We do this because we do not know the DLL name at the compile time.
|
|
|
|
|
Huh?
I thought the wrapper was in a separate DLL?
You need the C# DLL to be able to load the wrapper DLL which needs the C# DLL?
It still seems to me the wrapper should be doing the loading of the C# DLL, at which time
it can obtain the required class name.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
We use Managed C++ DLL to load the wrapper DLL which is C# DLL. This managed C++ DLL supplies the DLL name, class name to the wrapper DLL. The wrapper DLL loads the C# DLL. Creates the C# Class. The C# DLL uses another managed C++ DLL internally.
|
|
|
|
|
How many wrapper classes are there?
Which C++ DLL are you unable to delete, and which DLLs reference it and how?
The original appdomain shouldn't need anything besides the wrapper DLL.
Is the wrapper class derived from MarshalByRefObject?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am not able to delete the Managed C++ DLL referenced inside the C# DLL. I checked the loaded assembly list using GetAssemblies. Then I found out the the Managed C++ DLL used in C# DLL is also loaded in the default application domain even though I do not use it anywhere except the C# DLL.
|
|
|
|
|
We're going in circles now...
I still question your step 3:
3. Load the Pure C# DLL in the new applicaiton domain. This C# DLL uses
managed C++ DLL.
Seems to me that's the place it gets loaded into the "default" app domain.
Can you look at the loaded assembly list before and after step 3 to confirm?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you for your replies. I found the solution to my problem. The problem is because the Managed C++ DLL that has been used in C# DLL refers to native C++ DLLs that have already been loaded in the main application i.e. default application domain.
So when the managed C++ DLL is getting loaded via C# DLL, the framework instead of loading the native C++ DLL in the new applicaiton domain, uses the DLLs from the default application domain. This is causing the managed C++ DLL also to be loaded into the default application domain. Because of this reason I was not able to delete the managed C++ DLL.
|
|
|
|
|
Makes sense
Good job tracking it down and thanks for the update.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a dataGridView control which I wish to
1) retrieve a date from
2) subtract days from the retrieved date
3) see if todays date is greater than the the result of item (2)
4) set an appropriate image in one of the dataGridView columns
I have tried:
int alertDays = 0;
foreach (DataGridViewRow row in keyEventsDataGridView.Rows)
{
DateTime alertDate = (DateTime) row.Cells[4].Value;
foreach (DebtorDataSet.KeyEventsRow eventRow in debtorDataSet.KeyEvents)
{
if(eventRow.Code.ToString() == row.Cells["KeyEventCode"].Value.ToString())
{
alertDays = ((int) eventRow.AlertDays);
}
}
alertDate.AddDays(0 - alertDays);
if (DateTime.Compare(DateTime.Now, alertDate) < 0)
{
row.Cells["Status"].Value = keyEventIconsImageList.Images[0];
}
else
row.Cells["Status"].Value = keyEventIconsImageList.Images[1];
}
the line
DateTime alertDate = (DateTime) row.Cells[4].Value;
is giving me problems as it returns no value in debugging mode.
What should the correct syntax for this be please?
|
|
|
|
|
I believe the Value is a String, so you'll probably need to Parse the String into a DateTime object; try using DateTime.Parse() or DateTime.TryParse().
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Maybe because it is the end of the week (for me), but I'm still having trouble with the line:
DateTime alertDate = (DateTime) row.Cells[4].Value;
row.Cells[4].Value does return the expected date as a string, but I need to find a way to assign this to the DateTime variable 'alertDays' so that I can then manipulate the date as the application demands. I tried DateTime.Parse() without success right now.
Any further suggestions would be very much appreciated please.
|
|
|
|
|
I finally figured it out. The power of coffee!!!
|
|
|
|
|
hi. this has been bothering me for quite some time and i still havent figured it out.
i want to calculate hours and minutes between two dates and two different times.
example - an employe signs in on 2.10.2008 at 11:51. he signs out the same day at 22:50.
example 2 - employe signs in on 29.1.2008 at 23:10 and signs out the other day and the other month which starts with the next day (here are two problems - time goes to a new day and a new month) at 5:40.
how can i solve this. ive tried time spant but i dont fully understand its functionality because as far as i know the timespan function returns (with compare) only which given DATE (not time) is over (1,0,-1) or something.
Any other simple ideas?
Thanks in front and sorry for my bad english
Greets,
Matjaz
Força Barça!
|
|
|
|
|
Just subtract the first from the second. The timespan object will contain the number of days, hours, etc between them.
Timespan ts = DateTime2 - DateTime1
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Ok, i get the timespan... but which format do i have the DT1 and 2?
In my example the user has to set the date (selected by datetime component) by hand and also the time (time is set by two value changers... forgot how theyre called... (they have sidebars next to them to incr or decr the value).
Can u give me an example how this could work, as my user has to set his arrival time and date and also his going time and date.
Im sorry for the complications... maybe im just stupid while not understanding :S
Força Barça!
|
|
|
|
|
The resulting timespan structure have all the info that you need.
class Program
{
static void Main(string[] args)
{
DateTime entry = new DateTime(2008, 10, 2, 11, 51, 0);
DateTime exit = new DateTime(2008, 10, 2, 22, 50, 0);
TimeSpan difference = exit - entry;
Console.WriteLine("Hours : {0} - Minutes : {1} - Seconds : {2}", difference.Hours, difference.Minutes, difference.Seconds);
Console.ReadLine();
}
}
Hope this helps.
|
|
|
|
|
How to check, from C#, are files for complex script and rtl languages (Regional and Language settings) installed?
Thanks
|
|
|
|
|
I don't know if there it is built-in class (SystemInformation class might contain this information) for this but I suspect the settings are stored in system registry.
|
|
|
|
|
I did not find it there
Thank you for your answer
Edit: Or is there another way of checking whether right to left text will display correctly on my form?
modified on Thursday, October 30, 2008 11:29 AM
|
|
|
|