0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rundll32から呼び出すDLLを作ってみた

Last updated at Posted at 2020-11-17

はじめに

を参考にさせて頂きました。圧倒的感謝……!

環境

  • Windows 10 Home (64bit)
  • Visual Studio Community 2019

手順

プロジェクトの作成

プロジェクト テンプレート:空のプロジェクト [C++]
プロジェクト名:rdtest

プロジェクトのプロパティ
全般
構成の種類:ダイナミック ライブラリ (.dll)

ソースの記述

rdtest.cpp
# include <Windows.h>
# include <stdio.h>

extern "C" __declspec(dllexport)
void CALLBACK test1(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
	MessageBoxA(nullptr, lpszCmdLine, "rdtest", MB_OK);
}

extern "C" __declspec(dllexport)
void test2(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
	printf("dlltest[%s]\n", lpszCmdLine);
}

エクスポート名の確認

[ツール]→[コマンド ライン]→[開発者コマンド プロンプト]

dumpbin /exports rdtest.dll

      1    0 00001040 _test1@16 = _test1@16
      2    1 00001060 test2 = _test2

動作確認

rundll32 rdtest.dll _test1@16 hello, world

rundll32 rdtest.dll test2 hello, world > a.txt
dlltest[hello, world ]
コンソールには出力されないがリダイレクトは可能。

0
1
0

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?