#include <idc.idc>
static
messageName(ptr, message) {
if
(message == 1)
MakeComm(ptr,
"WM_CREATE"
);
else
if
(message == 2)
MakeComm(ptr,
"WM_DESTROY"
);
else
if
(message == 5)
MakeComm(ptr,
"WM_SIZE"
);
else
if
(message == 0x10)
MakeComm(ptr,
"WM_CLOSE"
);
else
if
(message == 0x18)
MakeComm(ptr,
"WM_SHOWWINDOW"
);
else
if
(message == 0x0100)
MakeComm(ptr,
"WM_KEYDOWN"
);
else
if
(message == 0x0101)
MakeComm(ptr,
"WM_KEYUP"
);
else
if
(message == 0x0102)
MakeComm(ptr,
"WM_KEYCHAR"
);
else
if
(message == 0x0110)
MakeComm(ptr,
"WM_INITDIALOG"
);
else
if
(message == 0x0111)
MakeComm(ptr,
"WM_COMMAND"
);
else
if
(message == 0x0112)
MakeComm(ptr,
"WM_SYSCOMMAND"
);
else
if
(message == 0x0113)
MakeComm(ptr,
"WM_TIMER"
);
else
if
(message == 0x0116)
MakeComm(ptr,
"WM_INITMENU"
);
else
if
(message == 0x0117)
MakeComm(ptr,
"WM_INITMENUPOPUP"
);
else
if
(message == 0x0126)
MakeComm(ptr,
"WM_MENUCOMMAND"
);
}
static
DefineStruct() {
auto idStruct;
idStruct = AddStrucEx(-1,
"AFX_MSGMAP_ENTRY"
,0);
if
(idStruct == 0)
return
0;
if
(AddStrucMember(idStruct,
"nMessage"
, 0, FF_DWRD|FF_DATA, -1, 4) != 0) {
Warning(
"\n1\n"
);
DelStruc(idStruct);
return
0;
}
if
(AddStrucMember(idStruct,
"nCode"
, 4, FF_DWRD|FF_DATA, -1, 4) != 0) {
Warning(
"\n2\n"
);
DelStruc(idStruct);
return
0;
}
if
(AddStrucMember(idStruct,
"nID"
, 8, FF_DWRD|FF_DATA, -1, 4) != 0) {
Warning(
"\n3\n"
);
DelStruc(idStruct);
return
0;
}
if
(AddStrucMember(idStruct,
"nLastID"
, 12, FF_DWRD|FF_DATA, -1, 4) != 0) {
Warning(
"\n4\n"
);
DelStruc(idStruct);
return
0;
}
if
(AddStrucMember(idStruct,
"nSignature"
, 16, FF_DWRD|FF_DATA, -1, 4) != 0) {
Warning(
"\n5\n"
);
DelStruc(idStruct);
return
0;
}
if
(AddStrucMember(idStruct,
"pFunction"
, 20, FF_DWRD|FF_0OFF, -1, 4) != 0) {
Warning(
"\n6\n"
);
DelStruc(idStruct);
return
0;
}
return
idStruct;
}
static
GenerateMFCMap(addr) {
auto idStruct, ptr, message, isOk;
idStruct = GetStrucIdByName(
"AFX_MSGMAP_ENTRY"
);
if
( idStruct == -1) {
idStruct = DefineStruct();
if
(idStruct == 0) {
Warning(
"\nCannot declare the structure\n"
);
return
;
}
}
ptr = addr;
isOk = 1;
while
( Dword(ptr) != 0) {
if
(MakeStructEx(ptr, 24,
"AFX_MSGMAP_ENTRY"
) == 0) {
isOk = 0;
break
;
}
messageName(ptr,Dword(ptr));
ptr = ptr + 24;
}
if
(isOk == 0) {
Warning(
"\nCannot set the structure at %x\n"
, addr);
}
else
{
Message(
"Completed"
);
}
return
;
}