Ignore:
Timestamp:
Feb 5, 2011, 11:43:01 PM (13 years ago)
Author:
イグトランス (egtra)
Message:

PSAPIを使用している箇所について、Toolhelp32と選択するよう修正

Location:
branches/egtra/ab5.0/abdev/BasicCompiler_Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/egtra/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp

    r773 r798  
    377377BOOL CALLBACK DlgCompile(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
    378378    extern HANDLE hDebugProcess;
     379    extern DWORD processIdDebug;
    379380    char temporary[MAX_PATH];
    380381    RECT rect;
     
    444445                            TerminateProcess(hDebugProcess,0);
    445446                            hDebugProcess=0;
     447                            processIdDebug = 0;
    446448
    447449                            //デバッグダイアログを終了
     
    475477                        TerminateProcess(hDebugProcess,0);
    476478                        hDebugProcess=0;
     479                        processIdDebug = 0;
    477480
    478481                        //デバッグダイアログを終了
  • branches/egtra/ab5.0/abdev/BasicCompiler_Common/CDebugThreadInfo.cpp

    r741 r798  
    44#include "DebugSection.h"
    55
     6#include <ProcessAndModule.h>
    67
    78//デバッグ用
     
    1011
    1112extern HANDLE hDebugProcess;
     13extern DWORD processIdDebug;
    1214extern DebugSectionCollection debugSectionCollection;
    1315
     
    6769
    6870    //マッピングされているモジュールのイメージベースを取得
    69     HMODULE array_hModule[1024];
    70     DWORD cbReturned;
    71     if(!EnumProcessModules( hDebugProcess, array_hModule, sizeof(HMODULE)*1024, &cbReturned )) return 0;
     71    //HMODULE array_hModule[1024];
     72    //DWORD cbReturned;
     73    //if(!EnumProcessModules( hDebugProcess, array_hModule, sizeof(HMODULE)*1024, &cbReturned )) return 0;
     74    auto modules = ActiveBasic::Common::GetModules(processIdDebug);
    7275
    73     int i;
    7476    HMODULE hTargetModule=0;
    75     for(i=0;i<(int)(cbReturned/sizeof(HMODULE));i++){
    76         if((LONG_PTR)array_hModule[i]<=(LONG_PTR)EIP_RIP(Context)){
    77             if(hTargetModule<array_hModule[i]) hTargetModule=array_hModule[i];
     77    for (std::size_t i = 0; i < modules.size(); ++i)
     78    {
     79        if ((LONG_PTR)modules[i]<=(LONG_PTR)EIP_RIP(Context))
     80        {
     81            if (hTargetModule<modules[i])
     82            {
     83                hTargetModule=modules[i];
     84            }
    7885        }
    7986    }
     
    8188    extern DWORD ImageBase;
    8289    if((HMODULE)(ULONG_PTR)ImageBase!=hTargetModule){
    83         for(i=0;i<debugSectionCollection.debugSections.size();i++){
     90        for(std::size_t i=0;i<debugSectionCollection.debugSections.size();i++){
    8491            if((HMODULE)(ULONG_PTR)debugSectionCollection.debugSections[i]->dwImageBase==hTargetModule){
    8592                debugSectionCollection.choice(i);
  • branches/egtra/ab5.0/abdev/BasicCompiler_Common/Debug.cpp

    r750 r798  
    99#include "../BasicCompiler_Common/debug.h"
    1010
     11#include <Path.h>
     12#include <ProcessAndModule.h>
     13
    1114char *OpBuffer;
    1215
     
    1417
    1518HANDLE hDebugProcess;
     19DWORD processIdDebug;
    1620
    1721DWORD _DebugSys_dwThreadID[MAX_DEBUG_THREAD];
     
    155159    TerminateProcess(hDebugProcess,0);
    156160    hDebugProcess=0;
     161    processIdDebug = 0;
    157162
    158163    //デバッグダイアログを終了
     
    435440    if( program.IsAttach() )
    436441    {
    437         //プロセスIDを元にハンドルを取得
    438         HANDLE hProcess;
    439         hProcess=OpenProcess(PROCESS_ALL_ACCESS,0, program.GetAttachProcessId() );
    440         if(!hProcess) goto AttachError;
    441 
    442         //そのプロセスにおける実行モジュールのインスタンスハンドルを取得
    443         HINSTANCE hModule;
    444         DWORD cbReturned;
    445         if(!EnumProcessModules( hProcess, &hModule, sizeof(HINSTANCE), &cbReturned )) goto AttachError;
     442        ////プロセスIDを元にハンドルを取得
     443        //HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,0, program.GetAttachProcessId() );
     444        //if(!hProcess)
     445        //{
     446        //  DebugMessage("アタッチに失敗しました。");
     447        //  return;
     448        //}
     449
     450        ////そのプロセスにおける実行モジュールのインスタンスハンドルを取得
     451        //HINSTANCE hModule;
     452        //DWORD cbReturned;
     453        //if(!EnumProcessModules( hProcess, &hModule, sizeof(HINSTANCE), &cbReturned ))
     454        //{
     455        //  DebugMessage("アタッチに失敗しました。");
     456        //  return;
     457        //}
    446458
    447459        //実行ファイル名を取得
    448         char tempOutputFileName[MAX_PATH];
    449         GetModuleFileNameEx(hProcess,hModule,tempOutputFileName,MAX_PATH);
    450         program.SetOutputFilePath( tempOutputFileName );
    451 
    452         CloseHandle(hProcess);
     460        auto tempOutputFilePath = ActiveBasic::Common::GetExecutableModulePath(program.GetAttachProcessId());
     461        program.SetOutputFilePath( tempOutputFilePath.string().c_str() );
     462
     463        //CloseHandle(hProcess);
    453464
    454465/*
     
    456467        pobj_DebugSection->load(program.GetOutputFilePath().c_str());*/
    457468
    458         if(!DebugActiveProcess( program.GetAttachProcessId() )){
    459 AttachError:
     469        if(!DebugActiveProcess( program.GetAttachProcessId() ))
     470        {
    460471            DebugMessage("アタッチに失敗しました。");
    461472            return;
     
    532543            else{
    533544Attach_DllLoad:
    534                 //アタッチした場合
    535                 GetModuleFileNameEx(hDebugProcess,(HINSTANCE)de.u.LoadDll.lpBaseOfDll,temporary,MAX_PATH);
     545                {
     546                    //アタッチした場合
     547                    auto path = ActiveBasic::Common::GetModuleFilePath(hDebugProcess, reinterpret_cast<HINSTANCE>(de.u.LoadDll.lpBaseOfDll));
     548                    strncpy_s(temporary, path.string().c_str(), _TRUNCATE);
     549                }
    536550            }
    537551
     
    562576            hDebugProcess=de.u.CreateProcessInfo.hProcess;
    563577            hMainThread=de.u.CreateProcessInfo.hThread;
     578            processIdDebug = de.dwProcessId;
    564579
    565580            if(debugSectionCollection.add((HMODULE)de.u.CreateProcessInfo.lpBaseOfImage)){
Note: See TracChangeset for help on using the changeset viewer.