|
Hi there ..
i looked up in the MSDN about this class
"applicationsecurityinfo"
and couldn't find enough information about it .
And not even in any blog .
Can anyone help me to understand what it is ?
|
|
|
|
|
|
First , i am sorry about my terrible english.
i have a problem to impersonate User account which Exist in the domain ,using md5 hash.
i am using the api's :LogonUser and DuplicateToken.
i had succeed impersonate in default way.
but, when i using the LogonUser i supplying username, password, domain etc..
and i want to use MD5 Hash instead of password parameter.
is there someone who know or have and idea impersonating using md5 hash?, i really appreciate .
|
|
|
|
|
LogonUser requires a plaintext password IIRC. Hashing is irreversible; you cannot practically retrieve the plaintext from the hash. What you might try is using encryption, which can be reversed, then writing a wrapper class which accepts the encrypted text, decrypts it and calls LogonUser with that
You could get the currently logged on user by using System.Security.Principal.WindowsIdentity.GetCurrent().Token, which would give you the same result as LogonUser - a handle
|
|
|
|
|
asafbs2004 wrote: but, when i using the LogonUser i supplying username, password, domain etc..
and i want to use MD5 Hash instead of password parameter.
You can't. The function has no options to accept a hash of the password instead of the plaintext version. It's the plaintext version of the password, or you don't impersonate the user. It's that simple.
|
|
|
|
|
hi guys...
i have a problem with the defraganalysis method...
ManagementClass objMC = new ManagementClass("Win32_Volume");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
int result = Convert.ToInt32(objMO.InvokeMethod("defraganalysis", new object[] { true }));
if(objMO["Name"].ToString().Equals("C:\\")) {
break;
}
}
this code works fine, i got the result number but how can i get the properties of the defraganalysis object? as you can see http://msdn.microsoft.com/en-us/library/aa389827(VS.85).aspx[^] ms sais:
uint32 DefragAnalysis(
[out] boolean DefragRecommended,
[out] object DefragAnalysis
);
yes, but how can i get the out parameters?? i've searched the whole internet, but i couldnt find the answer. thx a lot!
|
|
|
|
|
to use the out parameters it would be something like this:
bool recomend;
object analysis;
DefragAnalysis(out recomend, out analysis);
this would assign your local variables with data from within the function
if this is not your requirement then im sorry for misunderstanding the question
|
|
|
|
|
 Yeah, there's not much C# sample code for WMI anywhere -- including MSDN. That really sucks because WMI isn't very intuitive. I tested WMI for 8+ years and still struggle with some features...
The DefragAnalysis method returns 3 things: return code (which you got), a bool that indicates whether or not a defrag is recommended, and an instance of Win32_DefragAnalysis. The bool & instance get "wrapped" in an object array. All you have to do is tell the method where to put the objects. Think of the "outParams" array as a mailbox with 2 slots. Null values are fine.
Here's some sample code. (Note, it isn't necessary to specify scope for Vista or Server 2008 because the defaults are local machine & “root\cimv2”. I only included it for backward compatibility.)
using System;
using System.Management;
namespace DefragAnalysis
{
class Program
{
static void Main(string[] args)
{
try
{
string scope = @"\\.\root\cimv2";
string query = @"SELECT * FROM Win32_Volume WHERE Name = 'C:\\'";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
object[] outputArgs = new object[2];
foreach (ManagementObject volume in searcher.Get())
{
UInt32 result = (UInt32)volume.InvokeMethod("DefragAnalysis", outputArgs);
if (result == 0)
{
Console.WriteLine("Defrag Needed = {0}\n", outputArgs[0]);
ManagementBaseObject defragAnalysis = outputArgs[1] as ManagementBaseObject;
if (null != defragAnalysis)
{
foreach (PropertyData property in defragAnalysis.Properties)
{
Console.WriteLine("{0} = {1}", property.Name, property.Value);
}
}
}
else
{
Console.WriteLine("Method return code = 0x{0:X}", result);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Something bad happened.\n" + ex);
}
finally
{
Console.WriteLine("\npress any key to exit...");
Console.ReadKey();
}
}
}
} OUTPUT:
Defrag Needed = False
AverageFileSize = 210971
AverageFragmentsPerFile = 1.01
AverageFreeSpacePerExtent = 1486924
ClusterSize = 4096
ExcessFolderFragments = 2
FilePercentFragmentation = 0
FragmentedFolders = 2
FreeSpace = 51929346048
FreeSpacePercent = 43
FreeSpacePercentFragmentation = 30
LargestFreeSpaceExtent = 23083888640
MFTPercentInUse = 72
MFTRecordCount = 286135
PageFileSize = 0
TotalExcessFragments = 2833
TotalFiles = 250258
TotalFolders = 35176
TotalFragmentedFiles = 876
TotalFreeSpaceExtents = 34924
TotalMFTFragments = 3
TotalMFTSize = 403636224
TotalPageFileFragments = 0
TotalPercentFragmentation = 15
TotalUnmovableFiles = 149
UsedSpace = 66455265280
VolumeName =
VolumeSize = 118384611328
press any key to exit...
|
|
|
|
|
Hi all,
I’ve been stuck with this problem for around two days now, and have been trawling the forums looks for help.
Any help would be great.
I have a windows form application which calls external applications, including commandline calls to subversion.
I have a rich textbox on my forum where I redirect the output from cmd to. Everything works great, but the form freezes and the textbox does not show until I do a messagebox.show or something similar. I have come to the conclusion that I need to do the external processes on a worker thread. To be honest I have not got much further than that.
I have a function called commandLine() which takes various parameters such as command, working dir. etc. im thinking that I should place this on a separate thread but not sure how to go about it as within this function I redirect the output to another function which deals with putting the text into the rtb, and a text file.
I have been looking at the threading and the backgroundworker, but have no idea how to get started at all!
Any advice on how to get started, hints and tips, use threading or backgroundworker would be great. Just a quick summary:
Thread needs to take multiple parameters and pass various string values back to the form thread.
Hope this makes sense!
Cheers 
|
|
|
|
|
|
|
Lol we linked the same article.
|
|
|
|
|
Create a class that has a backgroundworker object in it, and have that backgroundworker object use a Process object to run your external app. I have some code that might help, but that means I would have to write an article to go with it.
I guess I could post it here... in a message...
[EDIT] Nope - it's too big to post here. I'll have to write an article.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The Device has 4 videos capture entrance, the difficulty is to have access the library.(Drivers and API)
Thanks by the atençao!!
|
|
|
|
|
How many times are you going to ask? Read the documentation of your devices and read the posts people have given you already.
Stop repeating your question.
|
|
|
|
|
I did a search to see if this has already been answered, but didn't find anything (if it's already been answered, please just point me in the right direction).
I need to find out how to switch off the computer at runtime, meaning from a program, not by pushing the button on the tower . I suppose I could just create a process using shutdown.exe with args, but that actually shuts down Windows, and I want to bypass that. I have seen it done in the past (but I don't remember what program did it). I'm hoping there's some unmanaged function call (to some dll somewhere) that will simply power off the machine with no dialogs or anything. Just beeooooop, the machine is off.
Anyone?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
I don't see why shutdown.exe would not suit this requirement.. to be honest I don't know of another way, and if it exists I'm not sure it would be entirely safe to the machine.
For no dialog, couldn't shutdown.exe -s -f work as you described?
|
|
|
|
|
EliottA wrote: to be honest I don't know of another way, and if it exists I'm not sure it would be entirely safe to the machine.
ExitWindowsEx[^] API does the job.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'll look into this one, thank you!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
shutdown.exe would shut down Windows and then turn off the machine (depending on the arguments). However, I wish to bypass the "shut down Windows" part and just turn off the machine from the program.
Yes, I know, it's not healthy. But I have a need regardless.
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
|
I'll look into this one, too, thank you!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Looking up WMI, it appears that the following should work like I want:
ManagementClass mc = new ManagementClass("CIM_PowerSupply");
object[] methodArgs = { 6, null };
object result = mc.InvokeMethod("SetPowerState", methodArgs);
However, the program crashes with a ManagementException, saying "This method is not implemented in any class." And, Microsoft's article on the SetPowerState function says "This method is currently not implemented by WMI. To use this method, you must implement it in your own provider."
It's kind of cruel to tease me with a function that doesn't actually do anything... Anyone know how it's supposed to be "implemented"?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
|
yes shutdown sucks with shutdown.exe, specially in older windows version eg. XP
here is the code i use to shut my pc down
void Shutdown()
{
ManagementClass W32_OS = new ManagementClass("Win32_OperatingSystem");
ManagementBaseObject inParams, outParams;
int result;
W32_OS.Scope.Options.EnablePrivileges = true;
foreach (ManagementObject obj in W32_OS.GetInstances())
{
inParams = obj.GetMethodParameters("Win32Shutdown");
inParams["Flags"] = ShutDown.ForcedShutdown;
inParams["Reserved"] = 0;
outParams = obj.InvokeMethod("Win32Shutdown", inParams, null);
result = Convert.ToInt32(outParams["returnValue"]);
if (result != 0) throw new Win32Exception(result);
}
}
public enum ShutDown
{
LogOff = 0,
Shutdown = 1,
Reboot = 2,
ForcedLogOff = 4,
ForcedShutdown = 5,
ForcedReboot = 6,
PowerOff = 8,
ForcedPowerOff = 12
}
When you test this, save all your work. There is no way to stop this thing.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|