Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
D

Darrel Q Pham

@Darrel Q Pham
About
Posts
17
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • force closing a crashed application.
    D Darrel Q Pham

    I was out of state for a while and did not get a chance to respond. It works. Thank you.

    C / C++ / MFC question

  • force closing a crashed application.
    D Darrel Q Pham

    Hi, my main program is being monitored by a manager type program via a heart beat. How do I use the manager type program to force close the application. Using WM_CLOSE or WM_DESTROY is useless because the message pump is not running anymore. Thank you.

    C / C++ / MFC question

  • Can I SendMessage() to another user's window within the same computer?
    D Darrel Q Pham

    Thank you. I have setup Server 2003 and created 2 user sessions, then tried using SendMessage() to communicate between two user sessions, which does not work. I've done much more searching and read that the hWnd global but is limited to the scope of the windows station. This makes sense in terms of security reasons, but sucks when I want more flexibility. I also came across a few messages that says hWnd is "system wide", which makes me confused again. I tested Named pipes and it works because it was designed to work across networks, so it will be the last resort. It would be nice to clear up the confusion though.

    C / C++ / MFC performance question

  • Can I SendMessage() to another user's window within the same computer?
    D Darrel Q Pham

    Thanks again. Another thing I forgot to mention is this will be for Server 2003, which allows multiple interactive station vs. XP which only allows one. I didnt mention this because I just found this out. I'm using XP right now, and this explains why I wrote my hwnd to a file(casting it as a dword) from program A in login/station A, and then open it with program B in login/station B, and failed when I attempt to use SendMessage with the hwnd that I read from the file. I will set up Server2003 to confirm this. From reading the links you guys gave me above, I think I can use OpenWindowStation() to open the login/station I want, use the hwinsta handle that the function returns, and use SetProcessWindowStation() to give my process access to that login/station. Then at this point I could use FindWindow() to find the window that I want to send the message to, and use SendMessage() to communicate with that window. When all is done, I can bring my process back to the previous login/station. This is unrelated, but if I said above is correct, does this mean I can launch my process in login/station A, set my process to belong to login/station B, create a thread in login/station B, spun an mfc dialog box inside that thread, set my process to belong to login/station A again, and it'll work correctly even if I have global variables that the dialog box accesses in my main process in the user A?

    C / C++ / MFC performance question

  • Can I SendMessage() to another user's window within the same computer?
    D Darrel Q Pham

    Thank you, this is exactly what I'm looking for.

    C / C++ / MFC performance question

  • Can I SendMessage() to another user's window within the same computer?
    D Darrel Q Pham

    Thank you, but that is not what I meant. I'm literally talking about another sending a message to a window on another user's login account. I have program A in Bob's login account communicating with program B in Alice's login account. Assume they are remote logging into the same computer. I use SendMessage() often in the same login, so I understand how it works in the local login. I did read somewhere that the HWND is like a global handle in the system, which means I could pass the HWND to another login and it'll make it valid, but I doubt that. I will verify this.

    C / C++ / MFC performance question

  • Can I SendMessage() to another user's window within the same computer?
    D Darrel Q Pham

    I've searched and could not get an answer, and thats why I asked. It seems to me that there's no way to specify the user/session that I'm sending to with the current SendMessage function. I think I'm missing something though. Yes I am aware of "letmegooglethatforyou.com"

    C / C++ / MFC performance question

  • Can I SendMessage() to another user's window within the same computer?
    D Darrel Q Pham

    If so, where do I start looking? I understand I can use shared memory and other IPCs, but I want to know about SendMessage() specifically.

    C / C++ / MFC performance question

  • How to pass data from MFC to Win 32 Console through windows messaging [modified]
    D Darrel Q Pham

    *bump* I know how to use shared memory and named pipes, but I want to know how to do it with Windows Messaging and for a Win 32 console app. Any help would be appreciated, even if its an answer telling me its impossible.

    C / C++ / MFC tutorial c++

  • CreateFileMapping and OpenFileMapping accross different users.
    D Darrel Q Pham

    Solution: The casting is wrong. Now I just have to find a way to pass my TCHAR array/string correctly.

    g_handle_SharedMemory[i_counter] = CreateFileMapping(
    INVALID_HANDLE_VALUE, // use paging file
    &l_securityattributes_AllAccessAttr, // default security
    PAGE_READWRITE, // read/write access
    0, // max. object size
    MAX_SH_MEM_SIZE, // buffer size
    "Global\\Shared Memory" ); //name of mapping object

    instead of

    g_handle_SharedMemory[i_counter] = CreateFileMapping(
    INVALID_HANDLE_VALUE, // use paging file
    &l_securityattributes_AllAccessAttr, // default security
    PAGE_READWRITE, // read/write access
    0, // max. object size
    MAX_SH_MEM_SIZE, // buffer size
    (LPTSTR)Somestring ); //name of mapping object

    C / C++ / MFC help security

  • CreateFileMapping and OpenFileMapping accross different users.
    D Darrel Q Pham

    I checked the service information with process explorer and it does show that SE_CREATE_GLOBAL_NAME(SeCreateGlobalPrivilege ) is set. CreateEvent(...) was set up and called similarly, and that works fine. I initially had problems with access violations with OpenEvent(...) but atleast I know there is something there, and I fixed that with creating an empty security attribute and passing that in with OpenEvent(...). This is beyond me. More ideas would greatly be appreciated.

    C / C++ / MFC help security

  • CreateFileMapping and OpenFileMapping accross different users.
    D Darrel Q Pham

    It still doesn't work. This is what I did. Perhaps I did something wrong here?

    //Adjust Token and privileges to set global shared memory space
    HANDLE l_handle_Token; //To Do Close handle
    TOKEN_PRIVILEGES l_tokenprivileges_myPrivileges;

    if( !OpenProcessToken( GetCurrentProcess(), TOKEN\_ADJUST\_PRIVILEGES | TOKEN\_QUERY, &l\_handle\_Token ) )
    {
    	WriteLog( g\_cLogFile, \_T("OpenProcessToken failed \\n")		);
    	return (FALSE);
    }
    
    LUID l\_luid\_ID;	
    if( !::LookupPrivilegeValue( NULL, SE\_CREATE\_GLOBAL\_NAME, &l\_luid\_ID ) )
    {
    	WriteLog( g\_cLogFile, \_T("LookupPrivilageValue failed \\n")		);
    	CloseHandle( l\_handle\_Token );
    	return (FALSE);
    }
    else 
    {
    	WriteLog( g\_cLogFile, \_T("LookupPrivilageValue successful \\n")		);
    	l\_tokenprivileges\_myPrivileges.PrivilegeCount = 1;
    	l\_tokenprivileges\_myPrivileges.Privileges\[0\].Luid = l\_luid\_ID;
    	l\_tokenprivileges\_myPrivileges.Privileges\[0\].Attributes = SE\_PRIVILEGE\_ENABLED;
    	AdjustTokenPrivileges( 
    		l\_handle\_Token, 
    		FALSE, 
    		&l\_tokenprivileges\_myPrivileges, 
    		sizeof(TOKEN\_PRIVILEGES), 
    		(PTOKEN\_PRIVILEGES)NULL, 
    		0 );
    	CloseHandle( l\_handle\_Token );
    }
    
    C / C++ / MFC help security

  • CreateFileMapping and OpenFileMapping accross different users.
    D Darrel Q Pham

    Yes it is enabled. Any other suggestions?

    C / C++ / MFC help security

  • CreateFileMapping and OpenFileMapping accross different users.
    D Darrel Q Pham

    Hi guys, I'm a new programmer and I'm using CreateFileMapping in my service and trying to open it up with my Process with user A. OpenFileMapping with user A returns a file not found error. I know the file mapping works if I open two processes with the same user. I was able to get two services to share a file mapping correctly. So this must mean that the file mapping is out of scope to user A. Please help.

    //Service
    TCHAR SharedMemoryName[] = _T("Global\\Shared Memory1");

    	HANDLE handle\_SharedMemory = CreateFileMappingA( 
    		INVALID\_HANDLE\_VALUE,	// use paging file
    		NULL,					// default security
    		PAGE\_READWRITE,			// read/write access
    		0,						// max. object size
    		MAX\_SH\_MEM\_SIZE,		// buffer size
    		(LPCSTR) SharedMemoryName ); //name of mapping object
    

    //Process launched by user A
    TCHAR SharedMemoryName[] = _T("Global\\Shared Memory1");

                HANDLE handle\_SharedMemory = OpenFileMappingA( 
    		FILE\_MAP\_ALL\_ACCESS, //read/write access
    		FALSE,				 //do not inherit the name
    		(LPCSTR) SharedMemoryName ); //name of mapping object
    
    C / C++ / MFC help security

  • How to pass data from MFC to Win 32 Console through windows messaging [modified]
    D Darrel Q Pham

    Hi everyone, I have been trying to send data through windows messaging from a dialog to a windows service, both of which I have created. I can send data from the service to the dialog fine, I just let OnCopyData handle it. My windows service, with my limited knowledge, doesn't have anything like that, I think. I created a thread in my windows service to look for messages. I know I can't cast the datastructure to a LPARAM or cast back the LPARAM to my datastructure, the code below just shows as an example what I want to do. If there is a way, please let me know. I look forward to be educated by you.

    void myMessageThread( VOID *)
    {

    MSG l\_msgMessage;	
        //Create hidden window for the dialog to capture the hwnd
    hWndMain = ::CreateWindow( \_T("STATIC"), \_T("Sample"), 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);	
    CString c\_CopyDataMessage;
    l\_msgMessage.hwnd = hWndMain;
    //Data structure I want to receive
    PCOPYDATASTRUCT l\_newdata; 
        //Loop forever
    while( GetMessage(&l\_msgMessage, hWndMain, 0, 0) !=100	){
    	if( l\_msgMessage.message == WM\_myCopyData ){
    		l\_newdata = (PCOPYDATASTRUCT)l\_msgMessage.lParam;		
    	}
    	TranslateMessage( &l\_msgMessage );
    	DispatchMessage( &l\_msgMessage );
    }
    

    }

    modified on Monday, November 17, 2008 9:30 PM

    C / C++ / MFC tutorial c++

  • System owned process that is accessible through a UI from differed Windows user
    D Darrel Q Pham

    No that is not exactly what I want. Person A still has to log off for person B to log on. I guess what I'm doing is not possible, but then again no one on this forum told me its impossible either. The answer I wanted most right now is, either its possible, or not.

    C / C++ / MFC help design debugging question learning

  • System owned process that is accessible through a UI from differed Windows user
    D Darrel Q Pham

    Before I say anything, I've done a lot of searches, and haven't had any luck yet. Also, I'm a beginner, so most like I'm not using the correct terms to describe what I want, so please excuse me. Thank you in Advance Lets say you have two monitors. You are using firefox and you want to just drag the firefox screen to the second monitor. Now instead of two monitors, you have two users remotely logged in to the same computer. User A wants to give you user B program 1 in its exact state. How do you do this? This is what I am doing now: Person A remotely log in as user A, and starts program 1. Person A ran into a problem with program 1 and requests help from person B. Person A logs off, so person B can remotely log on to user A, where person B can debug program 1 in the exact state where person A had it. This is what I want to do: Person A logs in as user A, and starts program 1. Person A ran into a problem with program 1 and requests help from person B. Person A sends the UI Window to person B who is remotely logged on as user B on the same computer. I don't know if this is even possible or if it makes sense.

    C / C++ / MFC help design debugging question learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups