#pragma once #include #include #include #pragma comment(lib, "user32.lib") namespace fa { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// /// Form1 の概要 /// public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: ここにコンストラクター コードを追加します // } protected: /// /// 使用中のリソースをすべてクリーンアップします。 /// ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Label^ label1; protected: private: /// /// 必要なデザイナー変数です。 /// System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// /// デザイナー サポートに必要なメソッドです。このメソッドの内容を /// コード エディターで変更しないでください。 /// void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->label1 = (gcnew System::Windows::Forms::Label()); this->SuspendLayout(); // // button1 // this->button1->Location = System::Drawing::Point(50, 45); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 23); this->button1->TabIndex = 0; this->button1->Text = L"button1"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(50, 89); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(35, 12); this->label1->TabIndex = 1; this->label1->Text = L"label1"; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(284, 262); this->Controls->Add(this->label1); this->Controls->Add(this->button1); this->Name = L"Form1"; this->Text = L"Form1"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { // MUGENのハンドルを取得する処理 HWND hWnd; DWORD dwPID; HANDLE ph; hWnd = FindWindow(NULL, L"M.U.G.E.N"); //ウィンドウハンドルを名称より取得、多重起動は放置。 GetWindowThreadProcessId(hWnd,&dwPID); //プロセスID取得 ph = OpenProcess(PROCESS_ALL_ACCESS,TRUE,dwPID); //プロセスハンドル取得、及び権限取得? char *lpData0; char *lpDataPP; // char *lpDataGametime; // char *lpDataRo; char *lpDataRoS; // char *lpDataP1name; char *lpDataP1life; // char *lpDataP2name; char *lpDataP2life; char *lpDataCtrlS; LPVOID EAX[1]; LPVOID EBX[2]; // LPVOID Gametime[1]; // LPVOID Round[3]; LPVOID RoundState[1]; // LPVOID P1name[0x0158-0x0020]; LPVOID P1Life[2]; // LPVOID P2name[0x0158-0x0020]; LPVOID P2Life[2]; LPVOID FlagON[1]; DWORD dwAccessByte; // 基本のアドレス EAX取得 // 004B5B4C:ポインタ → EAX[0] lpData0=(char *)0x004B5B4C; ReadProcessMemory(ph,lpData0,EAX,4,&dwAccessByte); // プレイヤー情報ポインタ取得 // EAX+B754h:1Pのポインタ → EBX[0] // EAX+B758h:2Pのポインタ → EBX[1] lpDataPP=(char *)EAX[0]; lpDataPP+=0xB754; ReadProcessMemory(ph,lpDataPP,EBX,8,&dwAccessByte); // ラウンド情報取得(現在未使用) // EAX+BC04h:ラウンド数 → Round[0] // EAX+BC08h:1P勝ち数 → Round[1] // EAX+BC0Ch:2P勝ち数 → Round[2] // lpDataRo=(char *)EAX[0]; // lpDataRo+=0xBC04; // ReadProcessMemory(ph,lpDataRo,Round,12,&dwAccessByte); // ゲームタイム(現在未使用)※MUGEN起動後の総試合の合計 1秒=60 // EAX+B3FCh:gametime // lpDataGametime=(char *)EAX[0]; // lpDataGametime+=0xB3FC; // ReadProcessMemory(ph,lpDataGametime,Gametime,4,&dwAccessByte); // ゲーム高速化ON // EAX+C934h:ゲームスピード高速化(Ctrl+S)フラグ FlagON[0] = (char *)0x01; //書き込み用データ フラグON用 lpDataCtrlS=(char *)EAX[0]; lpDataCtrlS+=0xC934; WriteProcessMemory(ph,lpDataCtrlS,FlagON,1,&dwAccessByte); // Name情報取得?(現在未使用というかよくわからない) // lpDataP1name=(char *)EBX[0]; // lpDataP1name+=0x0020; // ReadProcessMemory(ph,lpDataP1name,P1name,8,&dwAccessByte); // // lpDataP2name=(char *)EBX[1]; // lpDataP2name+=0x0020; // ReadProcessMemory(ph,lpDataP2name,P2name,8,&dwAccessByte); // ラウンドステート取得 // EAX+BC30h:ラウンドステート → RoundState[0] // ※常時監視 // 勝利モーションに以降したらHPを確認 lpDataRoS=(char *)EAX[0]; lpDataRoS+=0xBC30; int RoundEnd; //試合終了フラグ RoundEnd = 0; do{ ReadProcessMemory(ph,lpDataRoS,RoundState,4,&dwAccessByte); if((int)RoundState[0] == 4){ lpDataP1life=(char *)EBX[0]; lpDataP1life+=0x0160; ReadProcessMemory(ph,lpDataP1life,P1Life,8,&dwAccessByte); lpDataP2life=(char *)EBX[1]; lpDataP2life+=0x0160; ReadProcessMemory(ph,lpDataP2life,P2Life,8,&dwAccessByte); RoundEnd = 1; } }while(RoundEnd==0); //試合終了したらループを抜ける String^ a=L""; int P1L = (int)P1Life[0]; int P1LM = (int)P1Life[1]; int P2L = (int)P2Life[0]; int P2LM = (int)P2Life[1]; a = P1L.ToString() + L"/" + P1LM.ToString() + L":" + P2L.ToString() + L"/" + P2LM.ToString(); label1->Text=a; }; }