- Formatting fix. No code change

svn path=/trunk/; revision=38646
This commit is contained in:
Dmitry Chapyshev 2009-01-08 17:21:16 +00:00
parent 8560b3bcc3
commit 174b42a736

View file

@ -20,12 +20,11 @@ typedef DWORD (WINAPI *CMP_UNREGNOTIFY) (ULONG );
static HINSTANCE hSetupApi = NULL;
BOOL WINAPI _InternalLoadString
(
HINSTANCE hInstance,
BOOL
WINAPI
_InternalLoadString(HINSTANCE hInstance,
UINT uID,
PUNICODE_STRING pwstrDest
)
PUNICODE_STRING pwstrDest)
{
HRSRC hrsStringTable;
HGLOBAL hResource;
@ -47,12 +46,9 @@ BOOL WINAPI _InternalLoadString
(actual resource ids) start from 1. See (1) and (2)
*/
/* TODO: some sort of cache, here, would be great */
hrsStringTable = FindResourceW
(
(HMODULE)hInstance,
hrsStringTable = FindResourceW((HMODULE)hInstance,
MAKEINTRESOURCEW((uID / 16) + 1), /* (2) */
RT_STRING
);
RT_STRING);
/* failure */
if (hrsStringTable == NULL) return FALSE;
@ -103,13 +99,12 @@ BOOL WINAPI _InternalLoadString
/*
* @implemented
*/
int WINAPI LoadStringA
(
HINSTANCE hInstance,
int
WINAPI
LoadStringA(HINSTANCE hInstance,
UINT uID,
LPSTR lpBuffer,
int nBufferMax
)
int nBufferMax)
{
UNICODE_STRING wstrResStr;
ANSI_STRING strBuf;
@ -144,9 +139,14 @@ int WINAPI LoadStringA
strBuf.MaximumLength = nBufferMax * sizeof(CHAR);
strBuf.Buffer = lpBuffer;
retSize = WideCharToMultiByte(CP_ACP, 0, wstrResStr.Buffer,
retSize = WideCharToMultiByte(CP_ACP,
0,
wstrResStr.Buffer,
wstrResStr.Length / sizeof(WCHAR),
strBuf.Buffer, strBuf.MaximumLength, NULL, NULL);
strBuf.Buffer,
strBuf.MaximumLength,
NULL,
NULL);
if (!retSize)
{
@ -184,28 +184,23 @@ int WINAPI LoadStringA
/*
* @implemented
*/
int WINAPI LoadStringW
(
HINSTANCE hInstance,
int
WINAPI
LoadStringW(HINSTANCE hInstance,
UINT uID,
LPWSTR lpBuffer,
int nBufferMax
)
int nBufferMax)
{
UNICODE_STRING wstrResStr;
int nStringLen;
/* parameter validation */
if
(
(nBufferMax < 0) ||
(lpBuffer == NULL) ||
if ((nBufferMax < 0) || (lpBuffer == NULL) ||
((nBufferMax > 0) && IsBadWritePtr(lpBuffer, nBufferMax * sizeof(lpBuffer[0]))) ||
/* undocumented: If nBufferMax is 0, LoadStringW will copy a pointer to the
in-memory image of the string to the specified buffer and return the length
of the string in WCHARs */
((nBufferMax == 0) && IsBadWritePtr(lpBuffer, sizeof(lpBuffer)))
)
((nBufferMax == 0) && IsBadWritePtr(lpBuffer, sizeof(lpBuffer))))
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@ -250,17 +245,17 @@ int WINAPI LoadStringW
*/
HDEVNOTIFY
WINAPI
RegisterDeviceNotificationW(
HANDLE hRecipient,
RegisterDeviceNotificationW(HANDLE hRecipient,
LPVOID NotificationFilter,
DWORD Flags
)
DWORD Flags)
{
DWORD ConfigRet = 0;
CMP_REGNOTIFY RegNotify = NULL;
HDEVNOTIFY hDevNotify = NULL;
if (hSetupApi == NULL) hSetupApi = LoadLibraryA("SETUPAPI.DLL");
if (hSetupApi == NULL) return NULL;
RegNotify = (CMP_REGNOTIFY) GetProcAddress(hSetupApi, "CMP_RegisterNotification");
if (RegNotify == NULL)
{
@ -268,6 +263,7 @@ RegisterDeviceNotificationW(
hSetupApi = NULL;
return NULL;
}
ConfigRet = RegNotify(hRecipient, NotificationFilter, Flags, (PULONG) &hDevNotify);
if (ConfigRet != CR_SUCCESS)
{
@ -276,17 +272,21 @@ RegisterDeviceNotificationW(
case CR_OUT_OF_MEMORY:
SetLastError (ERROR_NOT_ENOUGH_MEMORY);
break;
case CR_INVALID_POINTER:
SetLastError (ERROR_INVALID_PARAMETER);
break;
case CR_INVALID_DATA:
SetLastError (ERROR_INVALID_DATA);
break;
default:
SetLastError (ERROR_SERVICE_SPECIFIC_ERROR);
break;
}
}
return hDevNotify;
}
@ -296,13 +296,14 @@ RegisterDeviceNotificationW(
*/
BOOL
WINAPI
UnregisterDeviceNotification(
HDEVNOTIFY Handle)
UnregisterDeviceNotification(HDEVNOTIFY Handle)
{
DWORD ConfigRet = 0;
CMP_UNREGNOTIFY UnRegNotify = NULL;
if (hSetupApi == NULL) hSetupApi = LoadLibraryA("SETUPAPI.DLL");
if (hSetupApi == NULL) return FALSE;
UnRegNotify = (CMP_UNREGNOTIFY) GetProcAddress(hSetupApi, "CMP_UnregisterNotification");
if (UnRegNotify == NULL)
{
@ -310,6 +311,7 @@ UnregisterDeviceNotification(
hSetupApi = NULL;
return FALSE;
}
ConfigRet = UnRegNotify((ULONG) Handle );
if (ConfigRet != CR_SUCCESS)
{
@ -318,15 +320,18 @@ UnregisterDeviceNotification(
case CR_INVALID_POINTER:
SetLastError (ERROR_INVALID_PARAMETER);
break;
case CR_INVALID_DATA:
SetLastError (ERROR_INVALID_DATA);
break;
default:
SetLastError (ERROR_SERVICE_SPECIFIC_ERROR);
break;
}
return FALSE;
}
return TRUE;
}