|
hi all,
Is there a way to get C# code again from C# Application EXE?
thanks in advance..
|
|
|
|
|
|
|
It's impossible to regenerate the original source code exactly how you wrote it. What you'll see is the equivalent code as translated from the IL.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hey everybody!
I'm serializing some strings in an application, but one of the string is a password. the thing is that when I go to the file that I'm serializing to, I can see with notepad the password clearly.
is there anyway to encode and decode this string before serializing it ?
|
|
|
|
|
Well here it is a function that i use to encode strings in XML files:
public static string ToB64(string text, Int16 type)<br />
{<br />
string rez = null;<br />
switch (type)<br />
{<br />
case 1:
rez = Convert.ToBase64String(Encoding.Unicode.GetBytes(text));<br />
break;<br />
case 2:
rez = Convert.ToBase64String(Encoding.ASCII.GetBytes(text));<br />
break;<br />
ase 3:
rez = Convert.ToBase64String(Encoding.UTF7.GetBytes(text));<br />
break;<br />
case 4:
rez = Convert.ToBase64String(Encoding.UTF8.GetBytes(text));<br />
break;<br />
}<br />
eturn rez;<br />
}
and to decode:
public static string FromB64(string text, Int16 type)<br />
{<br />
string rez = null;<br />
switch (type)<br />
{<br />
case 1:
rez = Encoding.Unicode.GetString(Convert.FromBase64String(text));<br />
break;<br />
case 2:
rez = Encoding.ASCII.GetString(Convert.FromBase64String(text));<br />
break;<br />
case 3:
rez = Encoding.UTF7.GetString(Convert.FromBase64String(text));<br />
break;<br />
case 4:
rez = Encoding.UTF8.GetString(Convert.FromBase64String(text));<br />
break;<br />
}<br />
return rez;<br />
}
|
|
|
|
|
I'm assuming you want to serialize your class with the XmlSerializer. The simplest trick is to mark your cleartext Password field/property with XMLIgnore and add another property providing an encrypted password.
using System;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Security.Cryptography;
[Serializable]
public class UserData
{
[XmlIgnore]
public string Password;
[XmlElement("Password", DataType = "base64Binary")]
[EditorBrowsable(EditorBrowsableState.Never)]
public byte[] EncryptedPassword
{
get
{
return YourEncryptMethod(Password);
}
set
{
Password = YourDecryptMethod(value);
}
}
}
Another possibility is to implement the IXmlSerializable interface and serialize your class manually.
HTH, Mark
|
|
|
|
|
Hi, anyone has an idea of how to call a function with the following signature
long csp2TimeStamp2Str(unsigned char *Stamp, char *value, long nMaxLength)
in C# I declare it like this
[DllImport("csp2.dll", EntryPoint="csp2TimeStamp2Str")]
public static extern int csp2TimeStamp2Str(
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder blah,
[MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer, int maxLength);
Thanks in advance
|
|
|
|
|
hi
pl check like this:-
[DllImport("csp2.dll",EntryPoint="csp2TimeStamp2Str",ExactSpelling=false,SetLastError=true)]
public static extern int csp2TimeStamp2Str(out char stamp,out char value,int maxLength);
regards,
pubudu.
|
|
|
|
|
Do you have any documentation?
The first parameter unsigned char *Stamp might be
1. a pointer to a simple value, possibly taken from an enumeration
ref char stamp
ref short stamp
[MarshalAs(UnmanagedType.U2)] ref YourEnumType stamp
2. a [In] null-terminated unicode string
[MarshalAs(UnmanagedType.LPWStr)] string stamp
3. a [Out/maybe In] null-terminated unicode string
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder stamp
4. a [In] data array, its length is given in parameter nMaxLength
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] char[] stamp
5. a [Out] data array, its length is the return value of the function
IntPtr stamp
This goes for the second parameter as well, except for the last two possibilities, one is an [Out] parameter, the other one is an [In] parameter.
Without some documentation it is very hard to tell.
Mark
|
|
|
|
|
How can i get my app to always beinfront of all other running programs, even when its not active (Just like the task manager)
If your task manager is not always on top go 'Options' --> 'Always on top'
|
|
|
|
|
In your Form's properties, find TopMost and set it to true.
Or, in the form's code:
this.TopMost = true;
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It may be that I just don't have enough coffee in me yet this morning but out of curiousity, if I have two apps with both set to TopMost which one actually appears on top? Guessing it would be the last one open but I may be wrong.
|
|
|
|
|
The last one opened gets the top spot in the Z-Order.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Out of curiosity (as well):
Is Z-Order shared among monitors or does each screen have its own Z-Order?
Meaning, if I have 2 programs which are set to top-most and I drag one to another screen, will it "stay" on top of others apps on that screen?
Im asking because the program I am writing would be ideal to have on top on a second screen, so I just was curious if setting "top-most" would be enough.
As usual, the user can easily disable "top-most" at the press of a menu item
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
If your desktop is shared among all the monitors, then the Z-Order is also shared among them. If not, then each monitor has it's own Z-Order.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Anyone know where I could get access to the icons Windows XP uses ? I'd like to use the native Windows icons in my own application. Specifically I'd like to use the icons that are present in the Control Panel. Is this possible ?
|
|
|
|
|
You might first want to consider, or better yet - find out for sure, if this is a copyright violation.
The icons you find in the control panel are stored in the control panel files themselves (*.CPL). The are articles here on CP that explain how to pull the icons out of various .EXE and .DLL files. .CPL files are pretty much just like .EXE's. Just search the articles for "extract icon".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You can google for a nice little tool called "Buddy Icon Grabber". It will extract all icons out of any .exe or .dll file for you.
It can also scan your machine for all icons and let you save them to different formats and sizes. However, this mode is a system-resources eater!
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Can anyone help in extracting the exe files in such a way that the exe file does not install but extracts the all the files in a separate folder?
|
|
|
|
|
I gues you need a Zip like utility.
There is a free zip lib made in C# here icsharpcode.net
|
|
|
|
|
thanks for ur response. No i don't want any zip like utility. if i use diagonostics.process...,start(),waitforexit(), the exe file is extracted to install, but i want the exe file to extract to be unzipped or stored & not installing the exe package.
|
|
|
|
|
You'll have to find out what the command line parameters are for the file you want to unpack. If the .EXE supports the functionality you want, you're in business, all you have to do is use the correct commandline parameters to tell the .EXE to unpack itself but not run its setup. If not, oh well...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
system.diagnostics.process.start("filename.zip"); will extract the file (if it is an exe file , it starts to install)...all i need is to unzip the filename.zip, so that i can store the unzipped contents in another folder.
thanks
|
|
|
|
|
If you start a .ZIP file, it'll open in whatever application is registered to handle .ZIP files. It won't unpack the thing unless you give the correct command line parameters.
An .EXE is a different story. Not every .EXE self installer uses the same compression engine, so the command line parameters are going to be different from .EXE to .EXE. Herein lies your problem. You can attempt to use launch WinZip, or whatever .ZIP application your using, with the .EXE name in place of the .ZIP filename you would normally use. For example, a hypothetical command line for unzipping a .ZIP file might be:
WinZip -u -s myfile.zip c:\myfolder
You can replace the .ZIP filename with the selfextracting .EXE to unpack it:
WinZip -u -s mysetup.exe c:\myfolder
The problem with launching an .EXE and getting it to unpack itself is you don't know ahead of time if the .EXE supports unpacking with launching, unpacking to a traget folder, or what the proper command line parameters are to get it to unpack. You can only guess at this stuff.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|