2011年8月27日星期六

ODbgScript源碼學習(七)

//在反彙編窗口上下文菜單下調用
int mruGetCurrentMenu(char* buf) {

char buf2[4096] = {0}; //定義為0,4096個字節的緩衝區buf2
char key[5];
int p=0;
int c,v;
string path;

HINSTANCE h=hinstModule(); //獲取它自身的模塊句柄
strcpy(key,"MRU "); //key為"mru"

for(int n=1; n<=5; n++) {
key[3]=n+0x30; //ASCII n

ZeroMemory(&buf2, sizeof(buf2));
Pluginreadstringfromini(h,key,buf2,0);
if (strlen(buf2)) {
if (PathFileExists(buf2)) {
buf[p]=0x32; p++;
buf[p]=key[3]; p++;
buf[p]=0x20; p++;
path=buf2;
c=path.rfind('\\') + 1;

while ( (v = strchr(&buf2[c],',')-&buf2[c]) > 0) {
buf2[c+v]='.';
}
while ( (v = strchr(&buf2[c],'{')-&buf2[c]) > 0) {
buf2[c+v]='[';
}
while ( (v = strchr(&buf2[c],'}')-&buf2[c]) > 0) {
buf2[c+v]=']';
}

strcpy(&buf[p],&buf2[c]); p+=strlen(&buf2[c]);
buf[p]=',';p++;
}
}
}
if (p>0) buf[--p]=0;

return p;

}

int mruGetCurrentMenu(HMENU mmru,int cmdIndex) {

char buf2[4096] = {0};
char key[5];
int c,v;
string path;

HINSTANCE h=hinstModule();
strcpy(key,"MRU ");

for(int n=1; n<=5; n++) {
key[3]=n+0x30; //ASCII n

ZeroMemory(&buf2, sizeof(buf2));
Pluginreadstringfromini(h,key,buf2,0);
if (strlen(buf2)) {
if (PathFileExists(buf2)) {
path=buf2;
c=path.rfind('\\') + 1;
AppendMenu(mmru,MF_STRING,cmdIndex+n,&buf2[c]); //應用菜單
}
}
}

return 1;
}


int mruCmdMenu(HMENU mmru,int cmdIndex) {

AppendMenu(mmru,MF_STRING,cmdIndex+1,"ESP定律");
return 1;
}




//MessageBox(hwmain,buf,"",MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST);

没有评论:

发表评论