2013年7月21日日曜日

新しい機能を追加してみる(Windows 8) その2-User Access Loggingを実装する

User Access Loggingに関するリファレンスを参照しつつ、実際のWindowsでの動きを忠実に再現するために、まず始めの方はwindows8 のそのままのヘッダーファイルを使用しましょう。
Winapifamily.hとUal.hというファイルがあるはずです。
このふたつのファイルをwineのinclude/フォルダにコピーします。
dlls/にualapiフォルダを作成します。
このフォルダ内にファイルを置いてdllを作るんです。いくつか必要なテキストファイルがありますので、用意してください。
ファイル:main.c Makefile.in ualapi.spec
その後、wineのコンパイル時にプロジェクトが認識されるように
configure configure.ac にプロジェクト名を追加します。
このへんがGUIアプリケーションと違い、面倒なのですが、仕方のないことです。
それぞれに同じような記述のされているところに
         wine_fn_config_dll ualapi enable_ualapi implib
         WINE_CONFIG_DLL(ualapi,,[implib])
と書き足します。
main.cを書きます。(※1)
ライセンスは必ず明記してください。wineにパッチを送るのでないのなら、LGPLでなくても構いません。
wine/debug.h,winbase.h,wine/unicode.hual.h,winapifamily.hはインクルードしてください。
WINE_DEFAULT_DEBUG_CHANNEL(ualapi);
とmain.cに書き足します。
DllMain関数を書きます。他のdllのmain.cからコピーしてください。
specファイルを書きます。
くわしくは別項で。
(※1)(下にLGPLライセンスのmain.cの例を書きます。参考にしてください。)
/*
 * main.c
 * This file is part of wine
 *
 * Copyright (C) 2013 - matyapiro31
 *
 * wine is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * wine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with wine. If not, see <http://www.gnu.org/licenses/>.
 */
#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wfext.h"

#include "wine/unicode.h"
#include "wine/debug.h"
#include "initguid.h"
#include "ual.h"

WINE_DEFAULT_DEBUG_CHANNEL(ualapi);

/*****************************************************
 * DllMain
 */
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
    switch (fdwReason)
    {
    case DLL_WINE_PREATTACH:
        return FALSE;    /* prefer native version */
    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hinstDLL);
        break;
    }
    return TRUE;
}

/*
 * Return S_OK
 */
HRESULT
WINAPI
UalStart(
    PUAL_DATA_BLOB Data){
    //UalData.RoleGuid
    return S_OK;
}

HRESULT
WINAPI
UalStop(
    PUAL_DATA_BLOB Data){
    return S_OK;
}

HRESULT
WINAPI
UalInstrument(
    PUAL_DATA_BLOB Data){
    return S_OK;
}

HRESULT
WINAPI
UalRegisterProduct(
    const WCHAR* wszProductName,
    const WCHAR* wszRoleName,
    const WCHAR* wszGuid){
    return S_OK;

}

0 件のコメント:

コメントを投稿