|
My xp system is the English version. but it can support Chinese Japanese, Korean after install East-Asia language package of Microsoft.
|
|
|
|
|
The easiest way to handle this is to change the font to Aerial Unicode MS. This font is installed n all machines that have office or some office app, like Excel or Word. Its not a Guarantee for all machines. For the other you need to install some other Unicode font.
You can do this by Changing the font properties on the main dialog box.
|
|
|
|
|
i have function
<br />
void CShowHandlesOfProc::AddHandlesToList(CListCtrl *m_list,DWORD pid)<br />
{<br />
int nItem=0;<br />
NTSTATUS status;<br />
PSYSTEM_HANDLE_INFORMATION handleInfo=new SYSTEM_HANDLE_INFORMATION;<br />
ULONG handleInfoSize ;<br />
HANDLE processHandle;<br />
ULONG i;<br />
<br />
_NtQuerySystemInformation NtQuerySystemInformation = <br />
(_NtQuerySystemInformation)GetLibraryProcAddress("ntdll.dll", "NtQuerySystemInformation");<br />
<br />
_NtDuplicateObject NtDuplicateObject =<br />
(_NtDuplicateObject)GetLibraryProcAddress("ntdll.dll", "NtDuplicateObject");<br />
<br />
_NtQueryObject NtQueryObject =<br />
(_NtQueryObject)GetLibraryProcAddress("ntdll.dll", "NtQueryObject");<br />
<br />
if(!(processHandle = OpenProcess(PROCESS_DUP_HANDLE|PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,pid))) return;<br />
<br />
<br />
DWORD size=sizeof(SYSTEM_HANDLE_INFORMATION);<br />
DWORD needed=0;<br />
status = NtQuerySystemInformation(SystemHandleInformation,handleInfo,size,&needed);<br />
<br />
if(!NT_SUCCESS(status))<br />
{<br />
if(needed==0)<br />
return ;<br />
delete handleInfo;<br />
size = needed + 1024;<br />
handleInfo= (PSYSTEM_HANDLE_INFORMATION)new BYTE[size];<br />
status = NtQuerySystemInformation(SystemHandleInformation,handleInfo,size,&needed);<br />
<br />
if(status==STATUS_INFO_LENGTH_MISMATCH)<br />
MessageBox(L"Khong du Length cho NtQuerySystem");<br />
<br />
if(!NT_SUCCESS(status))<br />
{<br />
delete handleInfo;<br />
return;<br />
}<br />
}<br />
for(i = 0; i < handleInfo->HandleCount; i++)<br />
{<br />
SYSTEM_HANDLE handle = handleInfo->Handles[i];<br />
HANDLE dupHandle = NULL;<br />
POBJECT_TYPE_INFORMATION objectTypeInfo=new OBJECT_TYPE_INFORMATION;<br />
DWORD sizeType=0;<br />
PVOID objectNameInfo;<br />
UNICODE_STRING objectName;<br />
ULONG returnLength;<br />
<br />
if(handle.ProcessId != pid) continue;<br />
<br />
status=NtDuplicateObject(<br />
processHandle,<br />
(HANDLE)handle.Handle,<br />
GetCurrentProcess(),<br />
&dupHandle,<br />
0,<br />
0,<br />
0<br />
);<br />
<br />
DWORD neededType=0;<br />
<br />
sizeType=sizeof(OBJECT_TYPE_INFORMATION);<br />
<br />
status=NtQueryObject(dupHandle,ObjectTypeInformation,objectTypeInfo,sizeType,&neededType);<br />
<br />
if(status==STATUS_INFO_LENGTH_MISMATCH)<br />
{<br />
sizeType=neededType+1024;<br />
<br />
status=NtQueryObject(dupHandle,ObjectTypeInformation,objectTypeInfo,sizeType,&neededType);<br />
<br />
<br />
}<br />
<br />
if(!NT_SUCCESS(status))<br />
{<br />
<br />
continue;<br />
<br />
}<br />
<br />
if((handle.GrantedAccess >= 0x0012019f)<br />
&& (handle.GrantedAccess != 0x001a019f)<br />
&& (handle.GrantedAccess != 0x00120189)<br />
&& (handle.GrantedAccess != 0x00100000)<br />
&& (handle.GrantedAccess > 0x700a9e13));<br />
{<br />
MessageBox(objectTypeInfo->Name.Buffer);<br />
}<br />
<br />
<br />
}<br />
free(handleInfo);<br />
<br />
CloseHandle(processHandle);<br />
<br />
return;<br />
}<br />
i got typeName of handle..but when this function got some handle Type Name..have erro : out of memory
i dont know...someone help me?
this is my struct
<br />
#define NT_SUCCESS(x) ((x) >= 0)<br />
#define STATUS_INFO_LENGTH_MISMATCH 0xc0000004<br />
<br />
#define SystemHandleInformation 16<br />
#define ObjectBasicInformation 0<br />
#define ObjectNameInformation 1<br />
#define ObjectTypeInformation 2<br />
<br />
typedef ULONG (NTAPI *_NtQuerySystemInformation)(<br />
ULONG SystemInformationClass,<br />
PVOID SystemInformation,<br />
ULONG SystemInformationLength,<br />
PULONG ReturnLength<br />
);<br />
typedef ULONG (NTAPI *_NtDuplicateObject)(<br />
HANDLE SourceProcessHandle,<br />
HANDLE SourceHandle,<br />
HANDLE TargetProcessHandle,<br />
PHANDLE TargetHandle,<br />
ACCESS_MASK DesiredAccess,<br />
ULONG Attributes,<br />
ULONG Options<br />
);<br />
typedef ULONG (NTAPI *_NtQueryObject)(<br />
HANDLE ObjectHandle,<br />
ULONG ObjectInformationClass,<br />
PVOID ObjectInformation,<br />
ULONG ObjectInformationLength,<br />
PULONG ReturnLength<br />
);<br />
<br />
typedef struct _UNICODE_STRING<br />
{<br />
USHORT Length;<br />
USHORT MaximumLength;<br />
PWSTR Buffer;<br />
} UNICODE_STRING, *PUNICODE_STRING;<br />
<br />
typedef struct _SYSTEM_HANDLE<br />
{<br />
ULONG ProcessId;<br />
BYTE ObjectTypeNumber;<br />
BYTE Flags;<br />
USHORT Handle;<br />
PVOID Object;<br />
ACCESS_MASK GrantedAccess;<br />
} SYSTEM_HANDLE, *PSYSTEM_HANDLE;<br />
<br />
typedef struct _SYSTEM_HANDLE_INFORMATION<br />
{<br />
ULONG HandleCount;<br />
SYSTEM_HANDLE Handles[1];<br />
} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;<br />
<br />
typedef enum _POOL_TYPE<br />
{<br />
NonPagedPool,<br />
PagedPool,<br />
NonPagedPoolMustSucceed,<br />
DontUseThisType,<br />
NonPagedPoolCacheAligned,<br />
PagedPoolCacheAligned,<br />
NonPagedPoolCacheAlignedMustS<br />
} POOL_TYPE, *PPOOL_TYPE;<br />
<br />
typedef struct _OBJECT_TYPE_INFORMATION<br />
{<br />
UNICODE_STRING Name;<br />
ULONG TotalNumberOfObjects;<br />
ULONG TotalNumberOfHandles;<br />
ULONG TotalPagedPoolUsage;<br />
ULONG TotalNonPagedPoolUsage;<br />
ULONG TotalNamePoolUsage;<br />
ULONG TotalHandleTableUsage;<br />
ULONG HighWaterNumberOfObjects;<br />
ULONG HighWaterNumberOfHandles;<br />
ULONG HighWaterPagedPoolUsage;<br />
ULONG HighWaterNonPagedPoolUsage;<br />
ULONG HighWaterNamePoolUsage;<br />
ULONG HighWaterHandleTableUsage;<br />
ULONG InvalidAttributes;<br />
GENERIC_MAPPING GenericMapping;<br />
ULONG ValidAccess;<br />
BOOLEAN SecurityRequired;<br />
BOOLEAN MaintainHandleCount;<br />
USHORT MaintainTypeList;<br />
POOL_TYPE PoolType;<br />
ULONG PagedPoolUsage;<br />
ULONG NonPagedPoolUsage;<br />
} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;<br />
|
|
|
|
|
After this statement
status = NtQuerySystemInformation(SystemHandleInformation,handleInfo,size,&needed);
the count is
handleInfo->HandleCount=39337 Your code then goes on to examine each of the handles to check if it belongs to the PID. After finding 26 handles, your code crashes in malloc with ENOMEM . As far as I can tell, up until then the buffer objectTypeInfo->Name.Buffer contains valid strings. So the good news is, your code seems to be working.
Maybe you could search for the specific APIs you're using, and check if you're calling them correctly? It looks like you're not freeing some memory buffer.
|
|
|
|
|
i try free objectTypeInfo but still stack over flow..
can you help me?..
so hard to use this Undocument Api....
|
|
|
|
|
Send me your email address and I will email some code. Please send to hdietrich@gmail.com
|
|
|
|
|
i sent code for you...plz help me
thanks so much
|
|
|
|
|
.
Some Day I Will Prove MySelf :: GOLD
modified on Monday, March 21, 2011 2:13 PM
|
|
|
|
|
The source is included with MFC.....
Steve
|
|
|
|
|
The majority of MFC class methods have equivalents in Win32; check the documentation on MSDN for any extra parameters needed. The CDC and CBitmap objects would be replaced by HDC and HBITMAP handles. It is simply a matter of reading the documentation and modifying the code according to the correct rules.
I must get a clever new signature for 2011.
|
|
|
|
|
|
goldenrose9 wrote: but this code doesn't work at all.
May I suggest you try using your debugger to find out why.
I must get a clever new signature for 2011.
|
|
|
|
|
In your Height and Width functions, the first argument to GetObject should be a HBITMAP, not a BITMAP*.
Judging from your original post, the HBITMAP to use would be pOldBitmapImage. In the second post, you assign NULL to this, which is inconsistent with what you do in your original post; you'd want to get the HBITMAP from dcImage and put that in pOldBitmapImage.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
|
|
google for it, you will find lots.
|
|
|
|
|
|
goldenrose9 wrote: nice joke.... Google. anyways thanx 4 d reply The only joke is that you consistently ask for answers you can find yourself, using google. If you expect people to take your questions seriously, then invest a little time to try to find the answer yourself, instead of expecting other people to do your work for you.
BTW, use of SMS speak is not acceptable on these forums.
|
|
|
|
|
|
Here's how it went:
- Hans suggested you could use the TransparentBlt function, and included a link to the MSDN documentation page to help you get started.
- You responded by asking for a sample, rather than trying to work it out for yourself.
- Hans suggested (quite rightly) that there were lots to be found if you use Google.
- You responded by saying you thought his answer was a joke, and thus not worth consideration.
- Hans explained that people are not going to help you unless you are prepared to at least try and do some of your own work.
- You responded by a childish show of petulance, just because people will not do what you are quite capable of doing for yourself.
I must get a clever new signature for 2011.
|
|
|
|
|
|
Hi,
I'm currently making a simple game. Pressing the down arrow places a box on the form. Pressing up shoots missiles(blue boxes) and creates multiple instances of m1 which is part of the missle class.
What I want to do is change the color of each missle as it collides with the red box. So far only the last missile changes color. The other instances of the missle class get ignored.
#include "stdafx.h"
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class object
{
public:
PictureBox^ Box3;
object( Form ^ form )
{
Box3 = gcnew PictureBox();
Box3->Left = 150;
Box3->Top = 50;
Box3->Width = 100;
Box3->Height = 100;
Box3->BackColor = System::Drawing::Color::Red;
form->Controls->Add(Box3);
}
};
public ref class missile
{
public:
PictureBox^ Box1;
Timer^ Timer1;
missile( Form ^ form )
{
Timer1 = gcnew Timer;
Timer1->Interval = 1;
Timer1->Start();
Box1 = gcnew PictureBox();
Box1->Left = 150;
Box1->Top = 240;
Box1->Width = 10;
Box1->Height = 10;
Box1->BackColor = System::Drawing::Color::Blue;
form->Controls->Add(Box1);
Timer1->Tick += gcnew System::EventHandler(this, &missile::timer1_Tick);
}
System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
Box1->Top -= 1;
}
};
public ref class Form1 : public Form
{
public:
PictureBox^ Box2;
missile^ m1;
object^ o1;
Timer^ Timer3;
bool x;
Form1()
{
x=false;
Timer3 = gcnew Timer();
Timer3->Interval = 1;
Timer3->Start();
Box2 = gcnew PictureBox();
Box2->BackColor = Color::Blue;
Box2->Top = 240;
Box2->Left = (this->Width / 2) - 40;
Box2->Width = 40;
Box2->Height = 10;
this->Controls->Add(Box2);
this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::Form_KeyDown);
Timer3->Tick += gcnew System::EventHandler(this, &Form1::timer3_Tick);
}
System::Void Form_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e)
{
if(e->KeyCode == Keys::Up){x=true;m1 = gcnew missile(this);m1->Box1->Left = Box2->Left + (Box2->Width / 2) - 10;}
if(e->KeyCode == Keys::Left){Box2->Left -= 4;}
if(e->KeyCode == Keys::Right){Box2->Left += 4;}
if(e->KeyCode == Keys::Down) {o1 = gcnew object(this); }
}
System::Void timer3_Tick(System::Object^ sender, System::EventArgs^ e)
{
if(x==true)
{
if(m1->Box1->Top == o1->Box3->Bottom){m1->Box1->BackColor = Color::Green;}
}
}
bool isColliding(PictureBox^ box1, PictureBox^ box3)
{
Rectangle r1 = m1->Box1->Bounds;
Rectangle r2 = o1->Box3->Bounds;
return r1.IntersectsWith(r2);
}
};
[STAThread]
int main()
{
Application::Run(gcnew Form1());
}
I also am trying to figure out how to remove the instances from memory after a set amount of time as too many instances slows the program.
Thanks for the help.
modified on Saturday, March 19, 2011 9:48 PM
|
|
|
|
|
Hi,
welcome to CodeProject. I have several comments on your code:
1.
you did something wrong when posting the code as all > signs became double-HTML-encoded (see the >), making things pretty hard to read.
2.
I don't understand at all why this would be a C/C++ question, it looks like C++/CLI to me; that is .NET's version of C++, and it has its own forum on CodeProject. The current one is for native, unmanaged C or C++ code.
3.
a timer interval of 1 msec is not what you are going to get, you may want to read my article here: Timer surprises, and how to avoid them[^].
4.
You are using a PictureBox for each missile; I wouldn't do that. All the PB does for you is remember its Location and show an image somewhere on your form. You could as well paint the image yourself, by overriding the Form's OnPaint method (or, what I prefer: by adding a Panel and overriding its OnPaint). So in more detail I would:
- define a little Missile class with a Point and a Color member, and a PaintMe(Graphics g, Point at) method.
- instantiate Missiles and hold them in a generic List.
- in the Form/Panel's OnPaint enumerate those Missiles and have each of them paint itself.
Doing so would allow you to run hundreds of missiles without things getting slow.
5.
Collision detection could benefit from the same list of Missiles (that is assuming multiple missiles are moving at the same time, either controlled by your key stuff, or maybe just by a timer). You could again enumerate the Missile instances, and for each of them check for a collision and act accordingly (change color, explode, break in two, whatever).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sorry about that. I fixed the post.
How would I get my code working using my current aproach. I will try to redo the code after I know whats wrong with it\fix it.
By enumerate do you mean to specify each missile individualy like
missile^ m1;
missile^ m2;
missile^ m3;
m1 = gcnew missile(this);
m2 = gcnew missile(this);
m3 = gcnew missile(this);
etc
|
|
|
|
|
Not really. This is how it would look in C#; C++/CLI allows similar stuff, I'm less fluent in it:
List<Missile> missiles=new List<Missile>();
for(int i=0; i<10; i++) {
Missile m=new Missile();
m.Location=new Point(100+33*i, 200*10*i);
m.SetColor(Color.Yellow);
missiles.Add(m);
}
foreach(Missile m in missiles) {
if (m.IsHit()) m.SetColor(Color.Green);
}
which illustrates you don't need individual variables for collectible items at all.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|