> For the complete documentation index, see [llms.txt](https://www.pentestwiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pentestwiki.com/defense-evasion/windows-api/getmodulehandlea.md).

# GetModuleHandleA

GetModuleHandleA는 현재 프로세스 주소 공간에 로드된 모듈 중에서 인자로 전달된 모듈을 찾아 베이스 주소를 반환하는 함수입니다

```cpp
HMODULE GetModuleHandleA(
  [in, optional] LPCSTR lpModuleName // 모듈 이름
);
```

## Example

```cpp
#include <windows.h>
#include <iostream>

int main() {
    HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");

    if (!hKernel32) {
        std::cout << "kernel32.dll not loaded\n";
        return 1;
    }

    std::cout << "kernel32.dll base address: 0x"
              << std::hex << hKernel32 << std::endl;

    return 0;
}
```

## References

{% embed url="<https://learn.microsoft.com/ko-kr/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlea>" %}
