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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.