tlhelp32.h,IMAGE_ODS_HEADER,IMAGE_NT_HEADER
tlhelp32.hは主にシステム内のある時点のプロセス,スレッド,モジュール,スタックを列挙するために用いられる.スナップショット システム自体はプロセスチェーンテーブル、スレッドチェーンテーブル、モジュールチェーンテーブル、スタックチェーンテーブルを維持しています.スナップショットはこのモデルのある時の複製品です.
CreateToolhelp 32 Snapshotでスナップショットを作成できます.スナップショットにより、Process 32 FirstとProcess 32 Nextを再利用する.プロセスチェーンテーブルを簡単に訪問できます.同じように他のチェーンテーブルを訪問することができます.注意ヒープチェーンテーブルを訪問するには、HEAPLIST 32、Heap 32 ListFirst()、Heap 32 ListNext()を使用し、HEAPENTRY 32ではありません.
簡潔で一般的な遍歴モデルを提供します.
for(BOOL fOK=Process32First(..,..);fOK;fOK=Process32Next(..,..)) {...}
もう一つ興味深い関数は次のとおりです.
Toolhelp32ReadProcessMemory
BOOL WINAPI Toolhelp32ReadProcessMemory( __in DWORD th32ProcessID, __in LPCVOID lpBaseAddress, __out LPVOID lpBuffer, __in SIZE_T cbRead, __out SIZE_T lpNumberOfBytesRead );
この関数は、プロセス内の開始アドレスから始まるメモリをバッファにコピーします.このようにして,PEファイルのDOSヘッダ,ファイルヘッダなどのプロセスのいくつかのヘッダ情報を得ることができる.
「windowsコアプログラミング」では、PEのDOSヘッダを読み取ることで、ヘッダのオフセット位置を取得し、ヘッダを読み取ることでモジュールの優先ベースアドレスを得ることができます.詳しくは『Windowsコアプログラミング』の該当コードを参照してください.
The first bytes of a PE file begin with the traditional MS-DOS header, called an IMAGE_DOS_HEADER<%2
IAMGE_についてDOS_HEADERで重要な情報は次のとおりです.
The first bytes of a PE file begin with the traditional MS-DOS header, called anIMAGE_DOS_HEADER. The only two values of any importance are e_magic and e_lfanew. The e_lfanew field contains the file offset of the PE header. The e_magic field (a WORD) needs to be set to the value 0x5A4D. There's a #define for this value, named IMAGE_DOS_SIGNATURE. In ASCII representation, 0x5A4D is MZ, the initials of Mark Zbikowski, one of the original architects of MS-DOS.
CreateToolhelp 32 Snapshotでスナップショットを作成できます.スナップショットにより、Process 32 FirstとProcess 32 Nextを再利用する.プロセスチェーンテーブルを簡単に訪問できます.同じように他のチェーンテーブルを訪問することができます.注意ヒープチェーンテーブルを訪問するには、HEAPLIST 32、Heap 32 ListFirst()、Heap 32 ListNext()を使用し、HEAPENTRY 32ではありません.
簡潔で一般的な遍歴モデルを提供します.
for(BOOL fOK=Process32First(..,..);fOK;fOK=Process32Next(..,..)) {...}
もう一つ興味深い関数は次のとおりです.
Toolhelp32ReadProcessMemory
BOOL WINAPI Toolhelp32ReadProcessMemory( __in DWORD th32ProcessID, __in LPCVOID lpBaseAddress, __out LPVOID lpBuffer, __in SIZE_T cbRead, __out SIZE_T lpNumberOfBytesRead );
この関数は、プロセス内の開始アドレスから始まるメモリをバッファにコピーします.このようにして,PEファイルのDOSヘッダ,ファイルヘッダなどのプロセスのいくつかのヘッダ情報を得ることができる.
「windowsコアプログラミング」では、PEのDOSヘッダを読み取ることで、ヘッダのオフセット位置を取得し、ヘッダを読み取ることでモジュールの優先ベースアドレスを得ることができます.詳しくは『Windowsコアプログラミング』の該当コードを参照してください.
The first bytes of a PE file begin with the traditional MS-DOS header, called an IMAGE_DOS_HEADER<%2
Toolhelp32ReadProcessMemory(dwProcessId, (PBYTE) pvModuleRemote + idh.e_lfanew, &inth, sizeof(inth), NULL);
// Verify the NT image header
if (inth.Signature == IMAGE_NT_SIGNATURE)
{
// This is valid NT header, get the image's preferred base address
pvModulePreferredBaseAddr = (PVOID) inth.OptionalHeader.ImageBase;
}
return(pvModulePreferredBaseAddr);
IAMGE_についてDOS_HEADERで重要な情報は次のとおりです.
The first bytes of a PE file begin with the traditional MS-DOS header, called anIMAGE_DOS_HEADER. The only two values of any importance are e_magic and e_lfanew. The e_lfanew field contains the file offset of the PE header. The e_magic field (a WORD) needs to be set to the value 0x5A4D. There's a #define for this value, named IMAGE_DOS_SIGNATURE. In ASCII representation, 0x5A4D is MZ, the initials of Mark Zbikowski, one of the original architects of MS-DOS.