Article View: borland.public.cppbuilder.nativeapi
Article #10532Extracting menu name from another process
From: jp
Date: Thu, 01 Apr 2004 22:56
Date: Thu, 01 Apr 2004 22:56
25 lines
1691 bytes
1691 bytes
Gives an access violation in user32.dll
void getMenuItem(HWND hWndMenu)
{
HMENU menu = GetMenu(hWndMenu);
MENUITEMINFO mi, *_mi; unsigned long pid;
HANDLE process;
GetWindowThreadProcessId(hWndMenu, &pid);
process=OpenProcess
(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMA
TION, FALSE, pid);
_mi=(MENUITEMINFO*)VirtualAllocEx(process, NULL, sizeof(MENUITEMINFO),
MEM_COMMIT, PAGE_READWRITE);
ZeroMemory(&mi, sizeof(MENUITEMINFO));
mi.cbSize = sizeof(MENUITEMINFO);
mi.fMask = MIIM_TYPE;
mi.fType = MFT_STRING;
mi.dwTypeData=NULL;
WriteProcessMemory(process, _mi, &mi, sizeof(MENUITEMINFO), NULL);
// this fails GetMenuItemInfo(menu, 1, true, _mi);
ReadProcessMemory(process, _mi, mi, sizeof(MENUITEMINFO), NULL);
int size = mi.cch;
VirtualFreeEx(process, _mi, 0, MEM_RELEASE);
Technical Details
Message-ID:
<406c9e67$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,9000e433ab0a74c6,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-01 15:10:17 PST From: "jp" <jphillips_2003@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Extracting menu name from another process Date: Thu, 1 Apr 2004 14:56:04 -0800 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 NNTP-Posting-Host: 12.162.10.2 Message-ID: <406c9e67$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1080860263 12.162.10.2 (1 Apr 2004 14:57:43 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail