LoginSignup
0

More than 3 years have passed since last update.

[Windows]OpenProcessを使用するときに難読化する理由

Posted at

OBSの内部に以下のソースコードがあります。

static inline HMODULE kernel32(void)
{
    static HMODULE kernel32_handle = NULL;
    if (!kernel32_handle)
        kernel32_handle = GetModuleHandleW(L"kernel32");
    return kernel32_handle;
}

static inline HANDLE open_process(DWORD desired_access, bool inherit_handle,
                  DWORD process_id)
{
    static HANDLE(WINAPI * open_process_proc)(DWORD, BOOL, DWORD) = NULL;
    if (!open_process_proc)
        open_process_proc = get_obfuscated_func(
            kernel32(), "NuagUykjcxr", 0x1B694B59451ULL);

    return open_process_proc(desired_access, inherit_handle, process_id);
}

わかりづらくされていますが内容としては単純にOpenProcessを呼んでいるだけです。
なぜこんなことをする必要があるのでしょうか。

宣言をみれば説明が書いてありますがA/Vsというのがなんなのかよくわかりませんでした。

/* this is a workaround to A/Vs going crazy whenever certain functions (such as
 * OpenProcess) are used */
extern void *get_obfuscated_func(HMODULE module, const char *str, uint64_t val);

ググってみるとズバリそのままの回答を見つけました。

Question / Help - win-capture: What's the benifit of using obfuscation when calling openprocess | OBS Forums

Because some braindead antivirus / antimalware software considers programs that use OpenProcess / CreateRemoteThread to be malware.

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0