|
Thanx
James T. Johnson wrote:
Its not a strong form of security; it only ensures that the assembly hasn't been modified since it was signed.
I know what u mean now . It happened a few months back, when i used an unsigned compiled assembly (no source available, well not to the project). It threw an exception and showed me the code of the assembly, without realising it , I modified the assembly to correct the problem. And I was total amazed to seen my changes was reflected, even though I never opened a source file from the assembly and recompiled it. I was very nice in this case, but I can see the security problem, especially in my case.
|
|
|
|
|
How can I display popup menu when I click on a items of list view?
When I overriden Click event of list view,it occures for both right click and left click.How can I manage it only for right click?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
You have two options :
The first is done by using the VS.NET Toolbox window and produces code like this :
this.ContextMenu = new System.Windows.Forms.ContextMenu();
Other, in your listview click handler :
if (this.MouseButtons==MouseButtons.Right)
System.Windows.Forms.ContextMenu.Show (this, this.MousePosition);
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Thanks.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Aloha everyone...I have a question:
How can I implement auto-updating to my app? I have created a simple TCP/IP application and I would like the client to be able to get the newest version from the server and overwrite itself with the new version.
Obviously this will create problems with trying to overwrite a file in use, so how do you do it?
- Does .NET provide built in "shadow copying"? (I know ASP.NET does)
- Does Windows provide a service to auto-copy a file once an application closes?
- Is there some black-book trick I am unaware of???
Any help would be really appreciated!
|
|
|
|
|
BITS
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
|
|
Thanks, but I'm not sure this does what I need. I have no problem getting the file to the client machine. I have written a simple TCP/IP system to download any size file from the server to the client.
The problem I am trying to figure out is how am I going to replace my application .EXE while it is running? Or rather, how do I smoothly exit the program, get the copy done and re-load (without user interaction).
I only ask because I see other programs doing this and it is very nice
|
|
|
|
|
|
floydboy58 wrote:
The problem I am trying to figure out is how am I going to replace my application .EXE while it is running? Or rather, how do I smoothly exit the program, get the copy done and re-load (without user interaction).
Have a look at System.Diagnostics.Process class. It's easy enough to run a "updater" app to close the process and restart an instance of of the main app.
Else forcefully close the program after an update, forcing the user to open the newly updated one.
Third option is to go the AppDomain way, but that can be scary (to me anyways )
Hope this helps
|
|
|
|
|
Have your application shell out to another application (then die) that is responsible for downloading the newer version then shelling out to get the new exe running.
My only question now is.... how do you update the updater?
|
|
|
|
|
Ray Cassick wrote:
My only question now is.... how do you update the updater?
I have an auto-update app that is a Windows Installer app.
I have a version check exe, that compares the version on my website every time it is invoked and if there is no new version, ShellExecutes the main app exe.
else, it ShellExecutes the link to setup.exe on my site.
Now when the setup is running, the app and the auto update is not in use and can be updated.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
|
is there any difference between IntPtr.Zero
and AfxGetInstanceHandle( ) ?
in what dll AfxGetInstanceHandle( ) is defiend ?
r00d0034@yahoo.com
|
|
|
|
|
am i dreaming, or is this the right code to get an equivilant HANDLE object for a process.
IntPtr tknPtr = IntPtr.Zero;
Process pr = Process.GetCurrentProcess();
IntPtr ptr = pr.Handle;
OpenProcessToken(pr.Handle, 0, out tknPtr); This is what i am using, but when i get the last error with Marshal.GetLastWin32Error() [after calling AdjustTokenPrivileges) it is returning an error code of 6 which i think is ERROR_INVALID_HANDLE.
In theory, the above code should get a handle to the processes tokens, but im not sure as i dont fully understand it all.
[and for those of you who are tired of these posts, i am very sorry, but this isnt just about me and my little method anymore, this is WAR against Advapi32.dll, and the depriving of privileges! ]
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nnamdi Onyeyiri wrote:
OpenProcessToken(pr.Handle,0, out tknPtr);
Now I have told you THAT cannot be ZERO.
You can see from the follow that 0 is not valid:
#define TOKEN_ASSIGN_PRIMARY (0x0001)
#define TOKEN_DUPLICATE (0x0002)
#define TOKEN_IMPERSONATE (0x0004)
#define TOKEN_QUERY (0x0008)
#define TOKEN_QUERY_SOURCE (0x0010)
#define TOKEN_ADJUST_PRIVILEGES (0x0020)
#define TOKEN_ADJUST_GROUPS (0x0040)
#define TOKEN_ADJUST_DEFAULT (0x0080)
#define TOKEN_ADJUST_SESSIONID (0x0100)
#define TOKEN_ALL_ACCESS_P (STANDARD_RIGHTS_REQUIRED |\
TOKEN_ASSIGN_PRIMARY |\
TOKEN_DUPLICATE |\
TOKEN_IMPERSONATE |\
TOKEN_QUERY |\
TOKEN_QUERY_SOURCE |\
TOKEN_ADJUST_PRIVILEGES |\
TOKEN_ADJUST_GROUPS |\
TOKEN_ADJUST_DEFAULT )
#if ((defined(_WIN32_WINNT) && (_WIN32_WINNT > 0x0400)) || (!defined(_WIN32_WINNT)))
#define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P |\
TOKEN_ADJUST_SESSIONID )
#else
#define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P)
#endif
#define TOKEN_READ (STANDARD_RIGHTS_READ |\
TOKEN_QUERY)
#define TOKEN_WRITE (STANDARD_RIGHTS_WRITE |\
TOKEN_ADJUST_PRIVILEGES |\
TOKEN_ADJUST_GROUPS |\
TOKEN_ADJUST_DEFAULT)
#define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
BTW, does Marshal.GetLastWin32Error() do the same as the GetLastError() in the Win API?
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
well this is what msdn says:
This method exists because it is not safe to make a direct platform invoke call to GetLastError to obtain this information. The common language runtime might have made internal calls to API's that overwrite the operating system maintained GetLastError.
Hmm nice
Nnamdi Onyeyiri wrote:
ok, now, if i was a computer, im sure all that code would make sense to me
That would be ideal for a flagged enum, lookout for them in the headers, its much better to use enums than to define endless constants. This what makes a strongly-typed language so nice I tried c++ once to test the intellisense, guess what it gave me a list of a few thousand different functions and constants. Alt - F4 did the job
So you would write it as (you can copy, its correct ):
[Flags]
public enum TokenAccessRights
{
ASSIGN_PRIMARY =(0x0001),
DUPLICATE =(0x0002),
IMPERSONATE =(0x0004),
QUERY =(0x0008),
QUERY_SOURCE =(0x0010),
ADJUST_PRIVILEGES =(0x0020),
ADJUST_GROUPS =(0x0040),
ADJUST_DEFAULT =(0x0080),
ADJUST_SESSIONID =(0x0100),
ALL_ACCESS_P =(STANDARD_RIGHTS_REQUIRED |
ASSIGN_PRIMARY |
DUPLICATE |
IMPERSONATE |
QUERY |
QUERY_SOURCE |
ADJUST_PRIVILEGES |
ADJUST_GROUPS |
ADJUST_DEFAULT ),
ALL_ACCESS =(ALL_ACCESS_P |
ADJUST_SESSIONID ),
READ =(STANDARD_RIGHTS_READ |
QUERY),
WRITE =(STANDARD_RIGHTS_WRITE |
ADJUST_PRIVILEGES |
ADJUST_GROUPS |
ADJUST_DEFAULT),
EXECUTE =(STANDARD_RIGHTS_EXECUTE),
}
[Flags]
public enum AccessMask
{
DELETE =(0x00010000),
READ_CONTROL =(0x00020000),
WRITE_DAC =(0x00040000),
WRITE_OWNER =(0x00080000),
SYNCHRONIZE =(0x00100000),
STANDARD_RIGHTS_REQUIRED =(0x000F0000),
STANDARD_RIGHTS_READ =(READ_CONTROL),
STANDARD_RIGHTS_WRITE =(READ_CONTROL),
STANDARD_RIGHTS_EXECUTE =(READ_CONTROL),
STANDARD_RIGHTS_ALL =(0x001F0000),
SPECIFIC_RIGHTS_ALL =(0x0000FFFF),
}
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
errr thanks, but i dont need that i need my code to work
You will need that too make your code work!* You will need to redefine your function as (this way u cannot go wrong (well mostly)).
[DllImport("Advapi32.dll")]
static extern bool OpenProcessToken(IntPtr ProcessHandle,
[MarshalAs(UnmanagedType.U4)] TokenAccessRight DesiredAccess,
out IntPtr TokenHandle);
* Found in the remarks, overlooked it a couple of times
Windows XP Professional: If the computer is joined to a workgroup and the "Force network logons using local accounts to authenticate as Guest" policy is enabled, the function fails. Note that this policy is enabled by default for a computer running Windows XP Professional that is joined to a workgroup.
|
|
|
|
|
How can I get name and number of NT services that installed on a machine in my program?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Has anyone got info on this?
I'm looking for code snippetts and some white papers ideally.
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
Never heard of it, can you give some more details?
|
|
|
|
|
You need to write a Managed C++ wrapper, and then call from other .NET assemblies. MQSeries headers are in C/C++.
Gaul
|
|
|
|