mirror of
https://github.com/reactos/reactos.git
synced 2025-07-01 17:21:22 +00:00
[UCRT] Import Microsoft.Windows.SDK.CRTSource version 10.0.22621.3
Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3 License: MIT
This commit is contained in:
parent
f1b60c66f0
commit
04e0dc4a7a
568 changed files with 115483 additions and 0 deletions
40
sdk/lib/ucrt/internal/GetModuleFileNameA.cpp
Normal file
40
sdk/lib/ucrt/internal/GetModuleFileNameA.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// GetModuleFileNameA.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Definition of __acrt_GetModuleFileNameA.
|
||||
//
|
||||
|
||||
#include <corecrt_internal_win32_buffer.h>
|
||||
|
||||
DWORD __cdecl __acrt_GetModuleFileNameA(
|
||||
HMODULE const hModule,
|
||||
char * const lpFilename,
|
||||
DWORD const nSize
|
||||
)
|
||||
{
|
||||
size_t const wide_buffer_size = MAX_PATH + 1;
|
||||
wchar_t wide_buffer[wide_buffer_size];
|
||||
|
||||
DWORD const amount_copied = GetModuleFileNameW(
|
||||
hModule,
|
||||
wide_buffer,
|
||||
wide_buffer_size
|
||||
);
|
||||
|
||||
if (amount_copied == 0) {
|
||||
__acrt_errno_map_os_error(GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
__crt_no_alloc_win32_buffer<char> filename_buffer(lpFilename, static_cast<size_t>(nSize));
|
||||
|
||||
errno_t const cvt = __acrt_wcs_to_mbs_cp(
|
||||
wide_buffer,
|
||||
filename_buffer,
|
||||
__acrt_get_utf8_acp_compatibility_codepage()
|
||||
);
|
||||
|
||||
return static_cast<DWORD>(filename_buffer.size());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue