|
Yes, it means you statically link against the run-time libraries as I said in my previous reply.
|
|
|
|
|
yes thanks for the hints.
|
|
|
|
|
Hello people!
In a "home project" i tried to inject a DLL into explorer's process with the "CreateRemoteThread" and the "Hook" method. Both seems to work fine for other processes (tried with notepad.exe, tried with a simple test app of my own...) but if i try to use explorer's process...major FAIL. The "CreateRemoteThread" method causes an instant reboot of the system. If i try to use the other method i either get "access denied" when trying to install a hook using SetWindowsHookEx into explorer's GUI thread, or if i install a global hook it simply does not get called for explorer only for other processes. With both methods i have enabled the "debug" privilege on "my own" process' access token.
So my question is simply this: does the system no longer allow DLL injecting into explorer? I googled around and i have found many references of this being possible, i mean, to inject DLLs to explorer with both methods, however, i did not find anything conclusive about this no longer being allowed, and since the articles that say it is possible are mostly rather old, things might have changed since then (new Service Packs came out, new patches for XP, and so on...). I checked my code against examples i have found online but i see no major differences, and i supose if the code itself was bad then it would not work for other processes either. I tried this on XP Pro SP3 if it matters.
Thanks for any hints in advance.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
modified on Wednesday, April 28, 2010 10:55 AM
|
|
|
|
|
Hi,
Code-o-mat wrote: The "CreateRemoteThread" method causes an instant reboot of the system.
I assure you that this is not normal. It sounds to me that you have a rogue security product or perhaps malware causing the reboot. I would recommend debugging the cause. Upon reboot a dump file should have been written into the %SYSTEMROOT%\windows\minidump folder.
I would recommend following the instructions here to determine the cause of the reboot.
How to read the small memory dump files that Windows creates for debugging[^]
Code-o-mat wrote: So my question is simply this: does the system no longer allow DLL injecting into explorer?
Yes you should be able to inject a DLL into the explorer process. Without looking at your code I cannot determine why it is failing.
Best Wishes,
-David Delaune
|
|
|
|
|
Hey!
Thanks for your words. Seems to be that the cause of the reboot is something else than i originally thought. When i tried the "windows hook" method and got the "access denied" message i assumed that it must be some security issue. I also tired the "code-cave" method on notepad and windows detected it and "shut down notepad to protect my security", this also streanghtened my assumption that it is somekind of "protect the user" mechanism. But after your post i started experimenting some more with the "Remote thread" method and i actually got the DLL into explorer, i also determined that the reboot comes when i try to use certain methods in the DLL, i also experienced deadlocks. For example, in the DLL i create a new thread which then would call "GetDesktopWindow" to get the handle of the desktop window but the thread seems to deadlock in this method, it never returns from it.
At this point i am clueless why this happens, if you have any pointers, please share. Thanks.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi all!
I meet a problem when I derive a class from CEdit. I want to use a font specficed by myself in it. Now I use the font in the message function of WM_CTLCOLOR in parent window of CEdit. The new font can be shown in CEdit. But when I double click the left-button or drag the mouse to select more than one character, the position of caret is wrong. I don't know how to fix it. Plz help me! Thx!
whiteclouds
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Have you already tried
to set a font at the WM_CREATE reaction ?
virtual void BeHappy() = 0;
|
|
|
|
|
In WM_CREATE of CEdit? What difference between this and the action I take?
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
I think,
the difference is the settings purpose:
- your choice: the drawing (I guess, not in the edit mode)
- my choice: system assignment (I guess, for drawing and editing as well)
When you will want to use the class for a dialog item,
you could place the setting in your OnInitDialog() function :
...
m_cYourEdit.SetFont(..);
...
virtual void BeHappy() = 0;
|
|
|
|
|
I had test your method. I add some codes into OnInitDialog() of parent window as below:
CColorEdit *pEdit = (CColorEdit*)GetDlgItem(IDC_ED_COLOR);
if(pEdit)
{
CDC *pDC = pEdit->GetDC();
if(pDC)
{
pDC->SelectObject(m_fnt);
}
}
Then m_fnt can't be shown. And when I select some characters, the caret isn't in correct position.
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Try it :
CWnd* pcWnd = GetDlgItem(IDC_ED_COLOR);
if (pcWnd->GetSafeHwnd()) {
pcWnd->SetFont(&m_cFont);
}
virtual void BeHappy() = 0;
|
|
|
|
|
Thx for your reply!
The position of caret is right now. But the font isn't be used in general. Only when I select the characters, the font can work.
That means, when not select any character, the OnPaint() respond function in the derived class hadn't work. Because I draw the characters using specific font in it. Maybe I make a mistake, isn't it?
Pls help me more! Thx!
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
It works in my OnInitDialog()
(I have not performed any font manipulations for WM_CTLCOLOR ) :
static CFont cFont;
cFont.CreatePointFont(120, _T("Arial"));
CWnd* pcWnd = GetDlgItem(IDC_EDIT1);
if (pcWnd->GetSafeHwnd()) {
pcWnd->SetFont(&cFont);
}
virtual void BeHappy() = 0;
|
|
|
|
|
I had test the code you provided. That can work correct. And I know that the problem was generated by my own class derived from CEdit. Thank you, Eugen Podsypalnikov!
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Fellow teachers, my English is poor it may be more vague expression, but also you are forgiven!(各位老师,我英语很差所以表达上可能比较模糊,还请您们见谅!)
I compiled CELayoutEditor this program when met a very difficult issue, the program has been in one place error, the error is as follows:
(我在编译 CELayoutEditor 这个程序的时候,碰到了一个很棘手的问题,该程序一直在一个地方报错,错误如下:)
error C3861: 'wxStrdupA': identifier not found
Code fragment:
(代码片段
Buffer.h header files:
#ifndef _WX_BUFFER_H
#define _WX_BUFFER_H
#include "wxchar.h"
#include <stdlib.h> // malloc() and free()
DEFINE_BUFFER(wxCharBuffer, char, wxStrdupA);
#if wxUSE_WCHAR_T
DEFINE_BUFFER(wxWCharBuffer, wchar_t, wxStrdupW);
#endif // wxUSE_WCHAR_T
wxchar.h header files:
#include <stdarg.h>
#include <string.h>
/* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
/* and VC++ for Windows CE don't provide it */
#if !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
/* use #define, not inline wrapper, as it is tested with #ifndef below */
#define wxStrdupA strdup
#endif
Can tell about what is wrong somewhere? Is there any way to solve this problem? Thank you!
(可以告诉一下是什么地方出现问题?有没有什么办法解决这个问题?谢谢!)
|
|
|
|
|
Have no idea where you got these codes, just try changing wxchar.h to be like this:
#include <stdarg.h>
#include <string.h>
#ifndef wxStrdupA
#define wxStrdupA strdup
#endif
|
|
|
|
|
I tried to modify your approach, or can not eliminate this error, I now have Mozhe the
(我试着用你的方法修改,还是不能消除这个错误,我现在已经没辙了)
Code is found in the online, open source
(代码是在网上找到的,开源的)
|
|
|
|
|
Try it (this code has good chances under CE and under PC as well) :
{
...
TCHAR* tszResult = _tcsdup(_T("先生"));
...
free(tszResult);
...
}
virtual void BeHappy() = 0;
|
|
|
|
|
What do you? Did not understand ah!
|
|
|
|
|
class A
{
int i;
public:
void func1() {cout << "func1" << endl;};
static void func2() {cout << "func2" << endl;};
void func3() {i =1; cout << "func3" << endl;};
};
template <class T> class Smart
{
private :
T *m_ptr;
public :
explicit Smart(T *p = 0) : m_ptr(p) {}
T& operator*() {return *m_ptr;}
T* operator->() {return m_ptr;}
~Smart() {delete m_ptr;}
};
int main()
{
Smart<A> s(0);
(*s).func1();
system("PAUSE");
}
On running it I saw that it prints "func1" but how it it possible. I initialize it as NULL.
|
|
|
|
|
Basically your problem is resumed to something like this:
A* a = NULL;
a->func1();
In fact, the code will not crash in such scenario because you do not access any member variable of the class. Class methods are similar to global function except that they take an additional implicit parameter: the 'this' pointer (in your case it will be NULL). So, as long as you don't access any class variable, the code will not crash. Try now to print the value of 'i' in func1 and you'll that the code will crash.
|
|
|
|
|
Weird as it might look, a instance of the class is not really needed when calling such method, try the following simple code:
#include <iostream>
using namespace std;
class A
{
public:
void show(){ cout << "The show must go on." << endl; }
};
int main()
{
A * pA = NULL;
pA->show();
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I tried this and it worked find. But I am still confusing why it is working. What are the scenarios in which this thing will work.
Does it mean that U can access methods from NULL pointer but not attribute?
|
|
|
|
|
akashag wrote: Does it mean that U can access methods from NULL pointer but not attribute?
Yes, try:
#include <iostream>
using namespace std;
class A
{
public:
int a;
A():a(1){}
void show(){ cout << "The show must go on." << endl; }
void dump(){ cout << "member value is << " << a << endl;}
};
int main()
{
A * pA = NULL;
pA->show();
pA->dump();
}
[added]
From a OOP point of view (IMHO) this is a point where object abstraction clashes with technical implementation.
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Wednesday, April 28, 2010 3:36 AM
|
|
|
|
|
Yes, as I said earlier a class method is similar as a global method (so, there is one single function even if there are mutliple instances of the class or even no instance at all). When the method is called, the address of the instance on which the function is called is passed to the function (the 'this' pointer). This means that as long as you don't access any variables of the class, you can perfectly call the function even if the instance is NULL.
|
|
|
|