Ignore:
Timestamp:
Mar 19, 2012, 1:59:48 AM (12 years ago)
Author:
イグトランス (egtra)
Message:

egtraブランチの内容をマージ。

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ab5.0/abdev

    • Property svn:ignore set to
      *.opensdf
      *.sdf
      *.suo
      *.user
      int
      ipch
      out
  • trunk/ab5.0/abdev/BasicCompiler_Common/Debug.cpp

    r750 r828  
    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    //デバッグダイアログを終了
     
    271276UserProc *GetSubFromObp(ULONG_PTR pos)
    272277{
    273     compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    274     while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     278    foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs())
    275279    {
    276         UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    277 
    278280        if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pos  &&
    279281            pos < rva_to_real(pUserProc->GetEndOpAddress()))
     
    406408            //ユーザーに実行ファイルを選択させる
    407409            extern HWND hOwnerEditor;
    408             extern LPSTR ExeFileFilter;
     410            extern const LPCSTR ExeFileFilter;
    409411            if(!GetFilePathDialog(hOwnerEditor,ExeFilePathForDll,ExeFileFilter,"デバッグ用の実行可能ファイルを指定してください。",1)) return;
    410412        }
     
    435437    if( program.IsAttach() )
    436438    {
    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;
     439        ////プロセスIDを元にハンドルを取得
     440        //HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,0, program.GetAttachProcessId() );
     441        //if(!hProcess)
     442        //{
     443        //  DebugMessage("アタッチに失敗しました。");
     444        //  return;
     445        //}
     446
     447        ////そのプロセスにおける実行モジュールのインスタンスハンドルを取得
     448        //HINSTANCE hModule;
     449        //DWORD cbReturned;
     450        //if(!EnumProcessModules( hProcess, &hModule, sizeof(HINSTANCE), &cbReturned ))
     451        //{
     452        //  DebugMessage("アタッチに失敗しました。");
     453        //  return;
     454        //}
    446455
    447456        //実行ファイル名を取得
    448         char tempOutputFileName[MAX_PATH];
    449         GetModuleFileNameEx(hProcess,hModule,tempOutputFileName,MAX_PATH);
    450         program.SetOutputFilePath( tempOutputFileName );
    451 
    452         CloseHandle(hProcess);
     457        auto tempOutputFilePath = ActiveBasic::Common::GetExecutableModulePath(program.GetAttachProcessId());
     458        program.SetOutputFilePath( tempOutputFilePath.string().c_str() );
     459
     460        //CloseHandle(hProcess);
    453461
    454462/*
     
    456464        pobj_DebugSection->load(program.GetOutputFilePath().c_str());*/
    457465
    458         if(!DebugActiveProcess( program.GetAttachProcessId() )){
    459 AttachError:
     466        if(!DebugActiveProcess( program.GetAttachProcessId() ))
     467        {
    460468            DebugMessage("アタッチに失敗しました。");
    461469            return;
     
    532540            else{
    533541Attach_DllLoad:
    534                 //アタッチした場合
    535                 GetModuleFileNameEx(hDebugProcess,(HINSTANCE)de.u.LoadDll.lpBaseOfDll,temporary,MAX_PATH);
     542                {
     543                    //アタッチした場合
     544                    auto path = ActiveBasic::Common::GetModuleFilePath(hDebugProcess, reinterpret_cast<HINSTANCE>(de.u.LoadDll.lpBaseOfDll));
     545                    strncpy_s(temporary, path.string().c_str(), _TRUNCATE);
     546                }
    536547            }
    537548
     
    562573            hDebugProcess=de.u.CreateProcessInfo.hProcess;
    563574            hMainThread=de.u.CreateProcessInfo.hThread;
     575            processIdDebug = de.dwProcessId;
    564576
    565577            if(debugSectionCollection.add((HMODULE)de.u.CreateProcessInfo.lpBaseOfImage)){
Note: See TracChangeset for help on using the changeset viewer.