したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | メール | |

管理人の独り言(プログラミング関連)

1069774さん:2008/12/11(木) 19:25:11 ID:CENbthlg0
ああ、面倒くさい。
もう辞めた。
まあ、方針としては、Sleipnirのプロセスハンドルを手に入れてWaitForSingleObjectで終了まで待って、終わったら、色々と解析して(ry
-----
#define STRICT 1

#if !defined(UNICODE) && !defined(_UNICODE)
#error UNICODE版でしかコンパイル出来んぞい。
#endif

#pragma comment(lib, "psapi.lib")

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <windows.h>
#include <lmcons.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <tchar.h>

using namespace std;

bool IsFileExist(wstring str){
FILE *file = _wfopen(str.c_str(), L"rb");
if(!file)
return false;
fclose(file);
return true;
}

//user.iniの入っているフォルダを頑張って探す
wstring GetSettingPath(){
WCHAR cur[MAX_PATH + 1];
GetCurrentDirectoryW(sizeof(cur) / sizeof(cur[0]) - 1, cur);

wstring currentPath(cur);

int UseAppData = 0, MultiUser = 1; //デフォルトらしい。:http://www.sleipnir-wiki.jp/index.php?Tips#w534cfdd
if(IsFileExist(currentPath + L"\\Sleipnir.Property")){ //存在するか
UseAppData = (int)GetPrivateProfileIntW(L"Setting", L"UseAppData", UseAppData, (currentPath + L"\\Sleipnir.Property").c_str());
MultiUser = (int)GetPrivateProfileIntW(L"Setting", L"MultiUser", MultiUser, (currentPath + L"\\Sleipnir.Property").c_str());
}

wstring base;
switch(UseAppData){
case 0:{ //Sleipnirインストールフォルダ以下
base = currentPath + L"\\..\\settings";

break;
}

case 1:{ //各ユーザーのApplication Dataフォルダ以下
base = L"%USERPROFILE%\\..";

break;
}

default:
return wstring(L"");
}
switch(MultiUser){
case 0:{ //All Users
base += L"\\All Users";
break;
}

case 1:{
WCHAR userName[UNLEN + 1];
DWORD size = sizeof(userName) / sizeof(userName[0]) - 1;
GetUserNameW(userName, &size);
base += L"\\";
base += userName;
break;
}

default:
return wstring(L"");
}
if(UseAppData == 1){
//TODO;
return wstring(L"");
}

return base;
}

int main(int argc, char **argv){
HANDLE hEnum = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hEnum == INVALID_HANDLE_VALUE) return -1;
PROCESSENTRY32 pe;
pe.dwSize = sizeof(pe);

Process32First(hEnum, &pe);
HANDLE hSleipnir = NULL;
do{
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pe.th32ProcessID);
if(hProcess){
HMODULE hMod;
DWORD needed;
EnumProcessModules(hProcess, &hMod, sizeof(hMod), &needed);
WCHAR path[MAX_PATH + 1];
GetModuleFileNameEx(hProcess, hMod, path, sizeof(path) / sizeof(path[0]) - 1);
int i = 0;
i++;
}
}while(Process32Next(hEnum, &pe));
CloseHandle(hEnum);


wstring settingPath = GetSettingPath();
if(settingPath == L"") return -1;
wstring userIniPath = settingPath + L"\\setting\\user.ini";

if(IsFileExist(userIniPath))
WritePrivateProfileStringW(L"SmartUpdater", L"LastCheckTime", L"\"14727\"", userIniPath.c_str());
}


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板