|
peterchen wrote:
Any recommendations?
Search for pugxml here at CP. Should be just what you want.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
|
Hi,
My purpose is:
- Write a service
- This service must create thread on every process (on every WindowStation)
Problem is:
CreateRemoteThread in MSDN wrote:
Terminal Services isolates each terminal session by design. Therefore,
CreateRemoteThread fails if the target process is in a different session
than the calling process.
If have many users is loging then have many session. I want to
CreateRemoteThread of every session.
My solution is:
- The first, find window station of the process which I must create thread
on it (use WTSEnumerateProcesses)
- The second, use SetProcessWindowStation to assign a window station to the
calling process (is my service). Result my service will operation on the
window station which I must create thread on a process on it.
- Then, use CreateRemoteThread to create thread. Now, CreateRemoteThread is
successful.
Is this solution true ?
Thank in advance.
PTM.
n4_t1
|
|
|
|
|
take a look at this hope it helps
#include "stdafx.h"
#pragma comment(linker,"/base:0x13140000")
DWORD WINAPI inject (void *)
{
MessageBox(0,"a","a",MB_OK);
ExitThread(0);
return 0;
}
void DisplayError(DWORD dwError )
{
LPTSTR lpBuffer = NULL;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpBuffer, 0, NULL );
if(dwError!=0) MessageBox(GetActiveWindow(), lpBuffer, "Error", MB_OK|MB_ICONERROR);
LocalFree( lpBuffer );
}
bool InjectCode(HANDLE process, LPTHREAD_START_ROUTINE lpCodeToInject)
{
PBYTE nume_exe;
DWORD dimensiune;
LPVOID m2;
nume_exe = (PBYTE)GetModuleHandle(0);
dimensiune = ((PIMAGE_NT_HEADERS)(nume_exe+((PIMAGE_DOS_HEADER)nume_exe)->e_lfanew))->OptionalHeader.SizeOfImage;
VirtualFreeEx(process, nume_exe, 0, MEM_RELEASE);
m2 = VirtualAllocEx(process, nume_exe, dimensiune, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!m2) return FALSE;
WriteProcessMemory(process, m2, nume_exe, dimensiune, NULL);
CreateRemoteThread(process, 0, 0, inject, NULL, 0, NULL);
return TRUE;
}
DWORD GetPID(char *szExe)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hProcessSnap, &pe32))
{
CloseHandle(hProcessSnap);
return 0;
}
do
{
if (lstrcmpi(pe32.szExeFile, szExe) == 0)
{
return (pe32.th32ProcessID);
break;
}
}
while (Process32Next(hProcessSnap, &pe32));
CloseHandle(hProcessSnap);
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HANDLE hProcess;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetPID("explorer.exe"));
InjectCode(hProcess, inject);
CloseHandle(hProcess);
return 0;
}
gabby
|
|
|
|
|
All,
I'm using a WebBrowser control in my dialog app, and was just wondering if there's some way of removing the border of the control, and in essence getting rid of that sunken look. Ideally I'd like the background of the control to integrate seamlessly with the background of it's parent dialog box, so there's no visual difference between control and dialog.
I think I might have to override the Create() function...
Any help would be appreciated,
Ritcho
|
|
|
|
|
This is supposed to work but doesn't for me. If you find out how please let me know.
HRESULT CDocHostHtmlView::OnGetHostInfo(DOCHOSTUIINFO * pInfo)
{
pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
return S_OK;
}
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hi All,
CString csRegHrs;
csRegHrs.Empty();
The next line produces the correct value Say 1000 (for 10.00) in csRegHrs.
csRegHrs = fcvt(m_pDSet->m_REGHRS,2,&decimal,&sign);
Can anyone explain to me why this isn't working.
csRegHrs.Format("%0.2lf");
The above line produces 0.00? Instead it should be 10.00?
I have stepped through the code and when I step into the csRegHrs.Format portion of the code it indicates in red text that it is 0.00 instead of 10.00.
I just don't get it. Any help would be appreciated.
Thanks,
Charlie
Everything is Free Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Charlie Curtis wrote:
Can anyone explain to me why this isn't working.
csRegHrs.Format("%0.2lf");
The above line produces 0.00? Instead it should be 10.00?
Given that the second parameter to Format() is missing, why would you expect it to work?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks for pointing that out. It is usually the simple ones that get you every time... I have put in the second parameter and it is now working fine.
Thanks
Charlie
Everything is Free Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
I can't compile the following code:
class Foo
{
public:
template< class T > void F() { T t; }
};
void main()
{
Foo tmp;
tmp.F < bool >();
}
The compile raises the error:
<br />
_samples.cpp(10) : error C2275: 'bool' : illegal use of this type as an expression<br />
_samples.cpp(0) : see declaration of 'bool'<br />
It raises the same error if I replace the bool type by a class.
It works if F is not declared as a member function.
It also works fine like this:
class Foo
{
public:
template<class T> void F(T bool) { T t; }
};
void main()
{
Foo tmp;
tmp.F(true);
}
How to do the call to have this working without having the type in param???
|
|
|
|
|
You have to declare the class as a template class.
template <class T> class foo
{
void F (T var) { cout << var; }
};
void main()
{
bool b = true;
foo<bool> tmp;
tmp.F(b);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
No, it's not the same purpose.
I really need the template for the member function, not for the class.
It's only for one function, not for the whole class
|
|
|
|
|
class foo
{
template <class T> void F (T var) { cout << var; }
};
void main()
{
bool B = true;
foo Foo;
Foo.F(B);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Yep, but it's not what I really wanna do
And in this case I prefer doing:
template < class T > void F (T *var) { ... }
and:
Foo.F((bool*)0);
Doing this way, the T object is not construct.
Nonetheless, it's a bit dodgie...
|
|
|
|
|
This is kinda difficult.. I used the following code piece:
class Foo
{
public:
template<typename T> void F() { T var; }
};<DIV>
void main()
{
Foo tmp;
tmp.F<bool>();
} This piece of code compiles properly, but issues a warning about an unreferenced local variable var which is what it should do as well.
Also, the first code piece you posted also compiles properly, but issues the same warning. I am using Visual Studio .NET 2003, so perhaps it's a compiler bug ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I guess it's a compiler issue.. I'm using VC6 sp5
I send this code to one on my friend which got exactly the same problem.
Worst: if you try to change the member function into a static member function, the compiler crashes.
|
|
|
|
|
Kandjar wrote:
template< class T > void F() { T t; }
That is a known problem in VC 6, that arises when the template parameter isn't present in the prototype. The common workaround is:
template< class T > void F(T* unused=NULL) { ... }
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Martin Kolberg, head of the local animal committee in Telemark, warns people to beware of drunken moose.
If my rhyme was a drug, I'd sell it by the gram.
|
|
|
|
|
I tried, but I'm still unable to do:
tmp.F< bool >();
Am I obliged to do
tmp.F((bool*)0);
to be able to use it?
|
|
|
|
|
I would like my output to be 4 hex digits.
0000 0001 0002 ... 000a 000b ... 0015
I am using the following loop to do this:
<br />
for (int i = 0; i <= 21; i++)<br />
{<br />
cout << setw(5) << hex << i << endl;<br />
}
It currently displays as
0 1 ... a b ... 15
Any help would be appreciated.
S.W.
|
|
|
|
|
printf( "%04x", 255 );
output will be
00FF
so what you want is probably
for( int i = 0; i <= 21; i++ )
{
printf( "%04x\n", i );
}
|
|
|
|
|
Thanks Archer,
Would you mind breaking the statement down for me or maybe you know of a link that would explain it to me. I appreciate your time.
|
|
|
|
|
Keep in mind that cout and printf() are not the same thing. The former is C++ while the later is C.
For a purely C++ solution, you simply need:
cout.fill('0');
cout << setw(5) << hex << i << endl;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Personally i prefer to use printf() over cout<<
but thats a matter of personal opinion
i really dont know how to explain printf()
you can look at microsofts description if it makes any sense
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_printf.2c_.wprintf.asp
but what i can do is give you some examples and maby you can pick up on it (note i figured it out from examples)
printf( "This is a %s", "test" );
output: This is a test
printf( "This is 282 in lowercase hex %x", 282 );
output: This is 282 in lowercase hex 11a
printf( "This is 282 in uppercase hex %X", 282 );
output: This is 282 in uppercase hex 11A
printf( "I was born %02d/%02d/%02d", 11, 28, 87 );
output: I was born 11/28/87
|
|
|
|
|
HICON hIcon;
LPBYTE lpBuffer;
hIcon=dlg.GetIconHandle();
lpBuffer=(LPBYTE)::GlobalLock(hIcon);
HANDLE hUpd=BeginUpdateResource("D:\\n.exe",0);
UpdateResource((HMODULE)hUpd,
RT_ICON,MAKEINTRESOURCE(1),
MAKELANGID(LANG_NEUTRAL,
SUBLANG_DEFAULT),
(LPBYTE)lpBuffer,
GlobalSize(hIcon));
EndUpdateResource(hUpd, FALSE);
GlobalUnlock(lpBuffer);
I'm using this code to take the icon from an exe and replace the icon in another exe, but it doesn't work. Every time lpBuffer is empty after GlobalLock. the hIcon handle is retrieved by ExtractIcon();
What am I doing wrong?
Please help!
|
|
|
|
|
I doubt you can do lpBuffer=(LPBYTE)::GlobalLock(hIcon); .
See this MSDN article[^] for more information on icons and resources. It links to a program written in C which has some code you can look at too.
Please note that the structs in the article are wrong. Look at the code in the linked project instead. I believe you will have to fill out an entire ICONDIR, as icons are stored that way (an icon can contain several images). Then the appropriate number of ICONDIRENTRYs and ICONIMAGEs. That's what's supposed to be inside the resource part.
But you are talking about replacing the icon in one exe from another one. I believe you can do the copy without too much work. Just grab a pointer to the icon resource in the source exe, and use it to update the icon entry in the other exe. I think that should work. The linked project has all the details. Good luck
--
Arigato gozaimashida!
|
|
|
|