Go Back   CodeCall Programming Forum > Software Development > C and C++
Register Blogs Search Today's Posts Mark Forums Read

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 01-21-2008, 07:10 PM
Newbie
 
Join Date: Jan 2008
Posts: 27
mholt is an unknown quantity at this point
Well, I'm game for complex and learning this stuff as long as it's easy to use in the end.

I really don't want you to feel as if you have to continue helping me with this, you've far exceeded what I expected as far as help goes. Take a break (unless you really want to, I mean, I won't stop ya) I have another semester starting up tomorrow, but I'll still be working on it. Again, thanks for all your help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 01-21-2008, 07:13 PM
dargueta's Avatar
Code Warrior
 
Join Date: Oct 2007
Age: 19
Posts: 2,602
dargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud of
You're welcome. Actually, I enjoy doing this--I'll take any chance to learn. Are you up for learning some Assembly language? We might have to do that for this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 01-21-2008, 08:06 PM
Newbie
 
Join Date: Jan 2008
Posts: 27
mholt is an unknown quantity at this point
Quote:
Originally Posted by dargueta View Post
You're welcome. Actually, I enjoy doing this--I'll take any chance to learn. Are you up for learning some Assembly language? We might have to do that for this.
Well, assembly language is taking it a little too far, I think... I am thinking right now of just handling one question at a time.

Would you want to help me develop this, perchance? I haven't found another app lightweight and free... so eh, there might be possibilities. It might be easier to collaborate our ideas...

Let me know; cause the first concept I want to tackle is the user-control thing, so that only the current logged-on user can have certain file permissions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 01-22-2008, 10:49 PM
dargueta's Avatar
Code Warrior
 
Join Date: Oct 2007
Age: 19
Posts: 2,602
dargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud of
You've got me really interested in this now. Of course I'd be happy to collaborate! It's not every day I meet a fellow programmer with the same interests.

A somewhat primitive way of tackling the user name issue is to use (once again) WinAPI to read the user name. If it's not yours, deny all access. I can't remember the function name offhand, but I'll check.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 01-22-2008, 11:01 PM
dargueta's Avatar
Code Warrior
 
Join Date: Oct 2007
Age: 19
Posts: 2,602
dargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud of
Found it--it's a really illogical name for the function:

C Code:
  1. char userBuffer[64];
  2. //erase the buffer - not necessary if done once, but if done
  3. //multiple times then yes.
  4. memset(userBuffer,NULL,64);
  5. //read the user name into the buffer
  6. ReadUserName(&userBuffer,63);
  7. //check the value of the user name
  8. if(strcmp("MyUserName",userBuffer) != 0)
  9.     printf("ACCESS DENIED.\n");

Last edited by dargueta; 01-22-2008 at 11:03 PM.. Reason: Clarified code w/ comment
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 01-23-2008, 04:49 PM
Newbie
 
Join Date: Jan 2008
Posts: 27
mholt is an unknown quantity at this point
Hmm... that code doesn't compile in Dev-Cpp under Windows. However, I found this that works:

Code:
char userBuffer[64];
DWORD nUserName = sizeof(userBuffer);
GetUserName(userBuffer, &nUserName);
cout << userBuffer << endl;
This successfully prints my current, logged-on, Windows NT (in my case, Vista, but works for XP and 2000 too) system.

Now the only problem would be to compare that to any user trying to do operations on the files...

Btw: I sent you a PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 01-23-2008, 10:10 PM
dargueta's Avatar
Code Warrior
 
Join Date: Oct 2007
Age: 19
Posts: 2,602
dargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud of
It doesn't compile because memset() and strcmp() aren't defined, right? You need to include memory.h and string.h.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 01-23-2008, 10:32 PM
dargueta's Avatar
Code Warrior
 
Join Date: Oct 2007
Age: 19
Posts: 2,602
dargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud ofdargueta has much to be proud of
I found a way that you can get the owning user name of a process, so you could do the following:
(1)Find all open handles to your file
(2)Get the IDs for the processes that own those handles
(3)Get the user names of those processes' owners
(4)Check the names against your own
(5)Use CancelIO() or something like that to invalidate the other handles.

I found an article on how to do #3, but I don't understand it; maybe you could:
Get Process User Name
It's in C#, of which I have no knowledge.

Here's something about #1...so it is possible, the question is how.
Getting open handles on a particular file

Last edited by dargueta; 01-23-2008 at 10:37 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 01-23-2008, 11:01 PM
Newbie
 
Join Date: Jan 2008
Posts: 27
mholt is an unknown quantity at this point
Quote:
Originally Posted by dargueta View Post
It doesn't compile because memset() and strcmp() aren't defined, right? You need to include memory.h and string.h.
Actually ReadUserName was undefined. But that's okay, got another function to work.

I'll look more into CancelIO(). That Handle thing is a downloadable app for system admins.

We can continue this via IM/email.

Toodles
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write the code for user to input command ? worried_student C and C++ 3 12-26-2007 09:11 PM
Future Windows User Interfaces for Applications totoliciu Pascal/Delphi 1 09-25-2007 09:59 AM
adding new nodes in a linked list while looping emda321 C and C++ 2 06-18-2007 03:27 AM
Java:Tutorial - User Input John Java Tutorials 0 12-09-2006 08:25 PM
Storing a Secure Password dirkfirst PHP Forum 7 07-22-2006 11:45 PM


All times are GMT -5. The time now is 08:15 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0