All of the most difficult and hard to find subjects covered in one unifying project. NT Master class encompasses a wide range of security functions, allowing you to create applications with a broad scope of features, that call through a single, powerful, class interface.
Features include interfaces into EFS (Encrypted File System), NTFS File Security, NTFS Registry Security, a wide array of User and Group management calls, and Service and Process management.
Class is written for speed and functionality, and includes error handling and events, along with a demonstration project.
The five worksheets from each subject are also included, so that you may use them seperately..
V3 is Up! Added some service functions, expanded user management, some small fixes/enhancements.
V4 is Up!
Added three new user management routines, applied some fixes to class and example.
V5 is Up!
Final rev is up, added 14 new functions!! All process functions mirrored to psapi for W2K server compliance. Added get/set thread priority, and get/set process class. Added Kill thread, load/unload user hive and create/remove user profile to user management. Now 60 functions in class, each one is now proofed and working well. Added an extended example to the demo, which goes through the complete cycle of adding/modifying a user/group, then launching a process with the new credentials.
V6 is Up!
Added a routine to service management, that changes the service description in mmc. Proofed and rewrote Service_Add and Service_Remove functions. Added optional machine name to service routines, making remote administration possible, (thanks Lite).
Hope ya like it..
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:
Re-scan downloaded files using your personal virus checker before using it.
NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Scan the source code with Minnow's Project Scanner
If you don't have a virus scanner, you can get one at many places on the net
Terms of Agreement:
By using this code, you agree to the following terms...
You may use
this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this code from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
Thanks Lite.. I could never find good examples of these things, so I felt this was needed. People, some things will work on 98/ME, like Service and Process management, but for the rest you need newer OS, (NT4/W2K/XP/2003/Vista). You need to have NTFS partition or NTFS controls are disabled automatically.. enjoy. John (If this comment was disrespectful, please report it.)
Wow, fantastic! I've been dabbling with some of this stuff recently as well, but you've taken care of everything and more. How you suffered through MSDN for all of this info I'll never know. :) 5 globes. (If this comment was disrespectful, please report it.)
Hi Joe, yes MSDN was big help, also binaryworld has good examples, and of course allapi.net. Lately though, I find it is just easier to read through header files for this stuff, usually name of call and structure are enough to figure it out, example, look in LMACCESS.H.. I've added a couple more routines, and expanded some others, expect an update in a couple of days. (If this comment was disrespectful, please report it.)
I was wondering about something... Does Windows XP Home have the needed files for creating encrypted files? I know you cannot set the attribute to "Encrypted" using Windows Explorer, but while you also cannot set what user is allowed to read the file, write to the file etc., the functionality is there because there is a tool that adds the Users tab to the properties dialog. (If this comment was disrespectful, please report it.)
Sebastion A couple prereqiusites first. Partition must be formatted with NTFS, (for Access Security and Encryption). You can see dialog for user permissions by going into explorer ->Tools -> Folder Options ->View tab and turn off 'Use Simple File Sharing'. Then Security tab should be visible on File/Folder properties, (..on an NTFS drive). As for Encryption, it is under Properties -> Advanced -> Encryption and Compression Attributes. Both encryption and NTFS security use calls primarily located in advapi32.dll. I don't imagine the two OSs (Pro/Home), would use a different library, if features are disabled I think it more likely it is simply absent or disabled at user options level, (if this app works on Home, then I guess this must be so).. (If this comment was disrespectful, please report it.)
Enmity, not all processes have modules.. try enum modules with vb6.exe selected, [for example], then you will see modules. NTFS drive is last NTFS partition found on hard drive. Check loops through partitions, checking each one for file system, if they are NTFS, it is returned true, if there are none, no NTFS partitions are present on your system. Path 'nmc\' is hard coded for sake of the example.. (If this comment was disrespectful, please report it.)
@Steppenwolfe what the process I am testing is definitely has modules, since I am now writing a large free tool and process explorer is one of them and I have accomplished that feature with EnumProcessModules from psapi.dll, I think Module32First/Module32Next is good for win9x/me, and EnumProcessModules is good for NT. (If this comment was disrespectful, please report it.)
and i think that you are missing some functions for process/thread: TerminateThread, GetPriorityClass,SetThreadPriority, even the "SetProcessWorkingSetSize"... (If this comment was disrespectful, please report it.)
Enmity, I am running XP, and it works fine here, maybe you are still using 2003 server? Of course there are a few more functions I could add, but it is a choice between making class too bulky, and adding features that are commonly used.. I may add terminate thread, and a couple more things, but next rev is likely to be the last. (If this comment was disrespectful, please report it.)
Hey all, added a bunch of new routines, and went through and proofed it all. Extended the example to demonstrate some of the new functions, and added options for kill thread, get/set thread priority and process class.. (If this comment was disrespectful, please report it.)
Also, all of process routines are now NT server compliant, routines mirrored to functions using psapi.dll, and 98/ME functions using kernal32.dll. (If this comment was disrespectful, please report it.)
I went over the project again today, testing every function, and found only one small bug. I re-uploaded with the fix, but if you want to do it yourself, it is pretty easy. Find the two api declarations in the NMC class: NetLocalGroupDel and NetGroupDel. Change the value types on both declartaions to: servername As Byte, groupname As Byte. Apply the same change to prjUsers class.. If you find anything else, just send me an email.. John (If this comment was disrespectful, please report it.)
Thanks to everyone who took the time to vote.. Glad you guys liked it, and I hope people get some use out of this. Expect another project in a week or so.. John (If this comment was disrespectful, please report it.)
Nice work! I think your work would really be of great help in system administration. Though the functions are available already via Windows OS yet what you did was a user-friendly consolidation which would really benefit people like us. Nice work! Definitely a 5 to you!!! (If this comment was disrespectful, please report it.)
5/18/2006 9:15:28 AM:
Wow! Veru cool code! (If this comment was disrespectful, please report it.)
Hi John, really great job and thx for suppporting AFTER submission it here! Suggestion: Don't skip this NICE little first parameter of e.g. OpenSCManager(...,..., ... ) in e.g. Service_Add(...) of clsServices ;-))) This would extend the usage for remote support applications a lot! I know, ok, final ... But: Whats really final in VB ;-) ? Kind regards - LiTe (If this comment was disrespectful, please report it.)
Hi Lite Yes, you can add domain qualifier to routines, maybe I will do it lator ;o) I am writing a 'true' service component now, so went back and borrowed some stuff from this class, hence the update. Maybe I will publish the service lator as an example.. (we'll see..) (If this comment was disrespectful, please report it.)
i'm Sorry PSC only allows me give Thanks and Rating Only upto 5* ! I will compain against it , Really ! Becoz coders like u need some more extra *s ! Keep Coding ! Make PSC outstanding with Codes like these . LET'S WORK HARD ! if ur intrested u can check my codes too . but not just like urs ! its simple ! But just check it ! Najeeb Puthiyallam ! firstname.lastname@example.org www.nsunlimited.blogspot.com (If this comment was disrespectful, please report it.)
John, all the times I red its not possible to write services in pure VB. The MS NTSVC.OCX is a very good solution to overcome this limitation, even with single step debugging in IDE! I 've used this control many times an it works perfectly stable from NT4 upto XP. If you need any additional DLL to get a VB service to run its not worth to substitute this OCX, only a pure VB solution, maybe with a tweak in compiler switches like the control panel solution submited today would be a good deal ;-)) (If this comment was disrespectful, please report it.)
Lite, I've already written the service in vb, (no form, no ocx, and runs unattended - it is running on my machine right now ;o) It uses a typelib, but could be done without it, (-but- there is nothing wrong with using a typelib, automation interface is used in many languages, and is a very handy thing, particularly in vb).. It was for a directory monitor I built, that I think is one of the best codes I have written. Maybe I will put an example together today.. (If this comment was disrespectful, please report it.)
hello i found a big problem in your "NTFS security program" if we have not user or group in file or folder security tab . program can't add users and change permissions but windows can add a users easily. can you please help me ? i really need help..! my e-mail: email@example.com (If this comment was disrespectful, please report it.)
@please answer me I have not programmed in vb6 in many years, and do not even have a compiler for it any more.. but the whole point of putting this source code up here was so that people can learn from and expand it. I learned how to use the api by searching the internet for scraps of code in various languages, (typically C for this sort of programming), and learning correct api call spec from msdn, I learned alot by doing the leg work, suggest you do the same.. (If this comment was disrespectful, please report it.)
thank you very much (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular code, please
click here instead.)