/*********************************************************************** * call_hook_AtoW */ static LRESULT call_hook_AtoW( HOOKPROC proc, INT id, INT code, WPARAM wparam, LPARAM lparam ) { LRESULT ret; UNICODE_STRING usBuffer; if (id != WH_CBT || code != HCBT_CREATEWND) ret = proc( code, wparam, lparam ); else { CBT_CREATEWNDA *cbtcwA = (CBT_CREATEWNDA *)lparam; CBT_CREATEWNDW cbtcwW; CREATESTRUCTW csW; LPWSTR nameW = NULL; LPWSTR classW = NULL; cbtcwW.lpcs = &csW; cbtcwW.hwndInsertAfter = cbtcwA->hwndInsertAfter; csW = *(CREATESTRUCTW *)cbtcwA->lpcs; if (!IS_INTRESOURCE(cbtcwA->lpcs->lpszName)) { RtlCreateUnicodeStringFromAsciiz(&usBuffer,cbtcwA->lpcs->lpszName); csW.lpszName = nameW = usBuffer.Buffer; } if (!IS_INTRESOURCE(cbtcwA->lpcs->lpszClass)) { RtlCreateUnicodeStringFromAsciiz(&usBuffer,cbtcwA->lpcs->lpszClass); csW.lpszClass = classW = usBuffer.Buffer; } ret = proc( code, wparam, (LPARAM)&cbtcwW ); cbtcwA->hwndInsertAfter = cbtcwW.hwndInsertAfter; HeapFree( GetProcessHeap(), 0, nameW ); HeapFree( GetProcessHeap(), 0, classW ); } return ret; }
/*********************************************************************** * FileSaveRestoreOnINFA (ADVPACK.@) * * See FileSaveRestoreOnINFW. */ HRESULT WINAPI FileSaveRestoreOnINFA(HWND hWnd, LPCSTR pszTitle, LPCSTR pszINF, LPCSTR pszSection, LPCSTR pszBackupDir, LPCSTR pszBaseBackupFile, DWORD dwFlags) { UNICODE_STRING title, inf, section; UNICODE_STRING backupdir, backupfile; HRESULT hr; TRACE("(%p, %s, %s, %s, %s, %s, %d)\n", hWnd, debugstr_a(pszTitle), debugstr_a(pszINF), debugstr_a(pszSection), debugstr_a(pszBackupDir), debugstr_a(pszBaseBackupFile), dwFlags); RtlCreateUnicodeStringFromAsciiz(&title, pszTitle); RtlCreateUnicodeStringFromAsciiz(&inf, pszINF); RtlCreateUnicodeStringFromAsciiz(§ion, pszSection); RtlCreateUnicodeStringFromAsciiz(&backupdir, pszBackupDir); RtlCreateUnicodeStringFromAsciiz(&backupfile, pszBaseBackupFile); hr = FileSaveRestoreOnINFW(hWnd, title.Buffer, inf.Buffer, section.Buffer, backupdir.Buffer, backupfile.Buffer, dwFlags); RtlFreeUnicodeString(&title); RtlFreeUnicodeString(&inf); RtlFreeUnicodeString(§ion); RtlFreeUnicodeString(&backupdir); RtlFreeUnicodeString(&backupfile); return hr; }
/*********************************************************************** * AdvInstallFileA (ADVPACK.@) * * See AdvInstallFileW. */ HRESULT WINAPI AdvInstallFileA(HWND hwnd, LPCSTR lpszSourceDir, LPCSTR lpszSourceFile, LPCSTR lpszDestDir, LPCSTR lpszDestFile, DWORD dwFlags, DWORD dwReserved) { UNICODE_STRING sourcedir, sourcefile; UNICODE_STRING destdir, destfile; HRESULT res; TRACE("(%p, %s, %s, %s, %s, %d, %d)\n", hwnd, debugstr_a(lpszSourceDir), debugstr_a(lpszSourceFile), debugstr_a(lpszDestDir), debugstr_a(lpszDestFile), dwFlags, dwReserved); if (!lpszSourceDir || !lpszSourceFile || !lpszDestDir) return E_INVALIDARG; RtlCreateUnicodeStringFromAsciiz(&sourcedir, lpszSourceDir); RtlCreateUnicodeStringFromAsciiz(&sourcefile, lpszSourceFile); RtlCreateUnicodeStringFromAsciiz(&destdir, lpszDestDir); RtlCreateUnicodeStringFromAsciiz(&destfile, lpszDestFile); res = AdvInstallFileW(hwnd, sourcedir.Buffer, sourcefile.Buffer, destdir.Buffer, destfile.Buffer, dwFlags, dwReserved); RtlFreeUnicodeString(&sourcedir); RtlFreeUnicodeString(&sourcefile); RtlFreeUnicodeString(&destdir); RtlFreeUnicodeString(&destfile); return res; }
/*********************************************************************** * AddDelBackupEntryA (ADVPACK.@) * * See AddDelBackupEntryW. */ HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir, LPCSTR lpcszBaseName, DWORD dwFlags) { UNICODE_STRING backupdir, basename; LPWSTR filelist; LPCWSTR backup; HRESULT res; TRACE("(%s, %s, %s, %d)\n", debugstr_a(lpcszFileList), debugstr_a(lpcszBackupDir), debugstr_a(lpcszBaseName), dwFlags); if (lpcszFileList) filelist = ansi_to_unicode_list(lpcszFileList); else filelist = NULL; RtlCreateUnicodeStringFromAsciiz(&backupdir, lpcszBackupDir); RtlCreateUnicodeStringFromAsciiz(&basename, lpcszBaseName); if (lpcszBackupDir) backup = backupdir.Buffer; else backup = NULL; res = AddDelBackupEntryW(filelist, backup, basename.Buffer, dwFlags); HeapFree(GetProcessHeap(), 0, filelist); RtlFreeUnicodeString(&backupdir); RtlFreeUnicodeString(&basename); return res; }
/*********************************************************************** * RegSaveRestoreA (advpack.@) * * See RegSaveRestoreW. */ HRESULT WINAPI RegSaveRestoreA(HWND hWnd, LPCSTR pszTitleString, HKEY hkBackupKey, LPCSTR pcszRootKey, LPCSTR pcszSubKey, LPCSTR pcszValueName, DWORD dwFlags) { UNICODE_STRING title, root, subkey, value; HRESULT hr; TRACE("(%p, %s, %p, %s, %s, %s, %d)\n", hWnd, debugstr_a(pszTitleString), hkBackupKey, debugstr_a(pcszRootKey), debugstr_a(pcszSubKey), debugstr_a(pcszValueName), dwFlags); RtlCreateUnicodeStringFromAsciiz(&title, pszTitleString); RtlCreateUnicodeStringFromAsciiz(&root, pcszRootKey); RtlCreateUnicodeStringFromAsciiz(&subkey, pcszSubKey); RtlCreateUnicodeStringFromAsciiz(&value, pcszValueName); hr = RegSaveRestoreW(hWnd, title.Buffer, hkBackupKey, root.Buffer, subkey.Buffer, value.Buffer, dwFlags); RtlFreeUnicodeString(&title); RtlFreeUnicodeString(&root); RtlFreeUnicodeString(&subkey); RtlFreeUnicodeString(&value); return hr; }
/*********************************************************************** * SetEnvironmentVariableA (KERNEL32.@) */ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value ) { UNICODE_STRING us_name; BOOL ret; if (!name) { SetLastError(ERROR_ENVVAR_NOT_FOUND); return 0; } RtlCreateUnicodeStringFromAsciiz( &us_name, name ); if (value) { UNICODE_STRING us_value; RtlCreateUnicodeStringFromAsciiz( &us_value, value ); ret = SetEnvironmentVariableW( us_name.Buffer, us_value.Buffer ); RtlFreeUnicodeString( &us_value ); } else ret = SetEnvironmentVariableW( us_name.Buffer, NULL ); RtlFreeUnicodeString( &us_name ); return ret; }
/* * @implemented */ BOOL WINAPI PrivilegedServiceAuditAlarmA(LPCSTR SubsystemName, LPCSTR ServiceName, HANDLE ClientToken, PPRIVILEGE_SET Privileges, BOOL AccessGranted) { UNICODE_STRING SubsystemNameU; UNICODE_STRING ServiceNameU; NTSTATUS Status; RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, (PCHAR)SubsystemName); RtlCreateUnicodeStringFromAsciiz(&ServiceNameU, (PCHAR)ServiceName); Status = NtPrivilegedServiceAuditAlarm(&SubsystemNameU, &ServiceNameU, ClientToken, Privileges, AccessGranted); RtlFreeUnicodeString(&SubsystemNameU); RtlFreeUnicodeString(&ServiceNameU); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } return TRUE; }
SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleA( SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry) { SECURITY_STATUS ret; TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry); if (pszPackage) { UNICODE_STRING principal, package; RtlCreateUnicodeStringFromAsciiz(&principal, pszPrincipal); RtlCreateUnicodeStringFromAsciiz(&package, pszPackage); ret = AcquireCredentialsHandleW(principal.Buffer, package.Buffer, fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry); RtlFreeUnicodeString(&principal); RtlFreeUnicodeString(&package); } else ret = SEC_E_SECPKG_NOT_FOUND; return ret; }
/*********************************************************************** * DoInfInstall (ADVPACK.@) * * Install an INF section. * * PARAMS * setup [I] Structure containing install information. * * RETURNS * S_OK Everything OK * HRESULT_FROM_WIN32(GetLastError()) Some other error */ HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup) { UNICODE_STRING title, inf, section, dir; SETUPCOMMAND_PARAMSW params; HRESULT hr; if (!setup) return E_INVALIDARG; RtlCreateUnicodeStringFromAsciiz(&title, setup->title); RtlCreateUnicodeStringFromAsciiz(&inf, setup->inf_name); RtlCreateUnicodeStringFromAsciiz(§ion, setup->section_name); RtlCreateUnicodeStringFromAsciiz(&dir, setup->dir); params.title = title.Buffer; params.inf_name = inf.Buffer; params.section_name = section.Buffer; params.dir = dir.Buffer; params.hwnd = setup->hwnd; hr = DoInfInstallW(¶ms); RtlFreeUnicodeString(&title); RtlFreeUnicodeString(&inf); RtlFreeUnicodeString(§ion); RtlFreeUnicodeString(&dir); return hr; }
/*********************************************************************** * RunSetupCommandA (ADVPACK.@) * * See RunSetupCommandW. */ HRESULT WINAPI RunSetupCommandA(HWND hWnd, LPCSTR szCmdName, LPCSTR szInfSection, LPCSTR szDir, LPCSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved) { UNICODE_STRING cmdname, infsec; UNICODE_STRING dir, title; HRESULT hr; TRACE("(%p, %s, %s, %s, %s, %p, %d, %p)\n", hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection), debugstr_a(szDir), debugstr_a(lpszTitle), phEXE, dwFlags, pvReserved); if (!szCmdName || !szDir) return E_INVALIDARG; RtlCreateUnicodeStringFromAsciiz(&cmdname, szCmdName); RtlCreateUnicodeStringFromAsciiz(&infsec, szInfSection); RtlCreateUnicodeStringFromAsciiz(&dir, szDir); RtlCreateUnicodeStringFromAsciiz(&title, lpszTitle); hr = RunSetupCommandW(hWnd, cmdname.Buffer, infsec.Buffer, dir.Buffer, title.Buffer, phEXE, dwFlags, pvReserved); RtlFreeUnicodeString(&cmdname); RtlFreeUnicodeString(&infsec); RtlFreeUnicodeString(&dir); RtlFreeUnicodeString(&title); return hr; }
/*********************************************************************** * TranslateInfStringA (ADVPACK.@) * * See TranslateInfStringW. */ HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSection, LPCSTR pszTranslateSection, LPCSTR pszTranslateKey, LPSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved) { UNICODE_STRING filenameW, installW; UNICODE_STRING translateW, keyW; LPWSTR bufferW; HRESULT res; DWORD len = 0; TRACE("(%s, %s, %s, %s, %p, %d, %p, %p)\n", debugstr_a(pszInfFilename), debugstr_a(pszInstallSection), debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey), pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved); if (!pszInfFilename || !pszTranslateSection || !pszTranslateKey || !pdwRequiredSize) return E_INVALIDARG; RtlCreateUnicodeStringFromAsciiz(&filenameW, pszInfFilename); RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection); RtlCreateUnicodeStringFromAsciiz(&translateW, pszTranslateSection); RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey); res = TranslateInfStringW(filenameW.Buffer, installW.Buffer, translateW.Buffer, keyW.Buffer, NULL, dwBufferSize, &len, NULL); if (res == S_OK) { bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); res = TranslateInfStringW(filenameW.Buffer, installW.Buffer, translateW.Buffer, keyW.Buffer, bufferW, len, &len, NULL); if (res == S_OK) { *pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL); if (dwBufferSize >= *pdwRequiredSize) { WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer, dwBufferSize, NULL, NULL); } else res = E_NOT_SUFFICIENT_BUFFER; } HeapFree(GetProcessHeap(), 0, bufferW); } RtlFreeUnicodeString(&filenameW); RtlFreeUnicodeString(&installW); RtlFreeUnicodeString(&translateW); RtlFreeUnicodeString(&keyW); return res; }
/* * @implemented */ BOOL WINAPI LogonUserA(LPSTR lpszUsername, LPSTR lpszDomain, LPSTR lpszPassword, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken) { UNICODE_STRING UserName; UNICODE_STRING Domain; UNICODE_STRING Password; BOOL ret = FALSE; UserName.Buffer = NULL; Domain.Buffer = NULL; Password.Buffer = NULL; if (!RtlCreateUnicodeStringFromAsciiz(&UserName, lpszUsername)) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto UsernameDone; } if (!RtlCreateUnicodeStringFromAsciiz(&Domain, lpszDomain)) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto DomainDone; } if (!RtlCreateUnicodeStringFromAsciiz(&Password, lpszPassword)) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto PasswordDone; } ret = LogonUserW(UserName.Buffer, Domain.Buffer, Password.Buffer, dwLogonType, dwLogonProvider, phToken); if (Password.Buffer != NULL) RtlFreeUnicodeString(&Password); PasswordDone: if (Domain.Buffer != NULL) RtlFreeUnicodeString(&Domain); DomainDone: if (UserName.Buffer != NULL) RtlFreeUnicodeString(&UserName); UsernameDone: return ret; }
/*********************************************************************** * TranslateInfStringExA (ADVPACK.@) * * See TranslateInfStringExW. */ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename, LPCSTR pszTranslateSection, LPCSTR pszTranslateKey, LPSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved) { UNICODE_STRING filenameW, sectionW, keyW; LPWSTR bufferW; HRESULT res; DWORD len = 0; TRACE("(%p, %s, %s, %s, %s, %ld, %p, %p)\n", hInf, debugstr_a(pszInfFilename), debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey), debugstr_a(pszBuffer), dwBufferSize, pdwRequiredSize, pvReserved); if (!pszInfFilename || !pszTranslateSection || !pszTranslateKey || !pdwRequiredSize) return E_INVALIDARG; RtlCreateUnicodeStringFromAsciiz(&filenameW, pszInfFilename); RtlCreateUnicodeStringFromAsciiz(§ionW, pszTranslateSection); RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey); res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer, keyW.Buffer, NULL, 0, &len, NULL); if (res == S_OK) { bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer, keyW.Buffer, bufferW, len, &len, NULL); if (res == S_OK) { *pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL); if (dwBufferSize >= *pdwRequiredSize) { WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer, dwBufferSize, NULL, NULL); } else res = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } HeapFree(GetProcessHeap(), 0, bufferW); } RtlFreeUnicodeString(&filenameW); RtlFreeUnicodeString(§ionW); RtlFreeUnicodeString(&keyW); return res; }
/* * @implemented */ BOOL WINAPI DefineDosDeviceA( DWORD dwFlags, LPCSTR lpDeviceName, LPCSTR lpTargetPath ) { UNICODE_STRING DeviceNameU = {0}; UNICODE_STRING TargetPathU = {0}; BOOL Result; if (lpDeviceName && ! RtlCreateUnicodeStringFromAsciiz(&DeviceNameU, (LPSTR)lpDeviceName)) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } if (lpTargetPath && ! RtlCreateUnicodeStringFromAsciiz(&TargetPathU, (LPSTR)lpTargetPath)) { if (DeviceNameU.Buffer) { RtlFreeHeap(RtlGetProcessHeap (), 0, DeviceNameU.Buffer); } SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } Result = DefineDosDeviceW(dwFlags, DeviceNameU.Buffer, TargetPathU.Buffer); if (TargetPathU.Buffer) { RtlFreeHeap(RtlGetProcessHeap (), 0, TargetPathU.Buffer); } if (DeviceNameU.Buffer) { RtlFreeHeap(RtlGetProcessHeap (), 0, DeviceNameU.Buffer); } return Result; }
/************************************************************************ * FD31_MapOfnStructA [internal] * map a 32 bits Ansi structure to an Unicode one */ void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW, BOOL open) { UNICODE_STRING usBuffer; ofnW->lStructSize = sizeof(OPENFILENAMEW); ofnW->hwndOwner = ofnA->hwndOwner; ofnW->hInstance = ofnA->hInstance; if (ofnA->lpstrFilter) ofnW->lpstrFilter = FD31_MapStringPairsToW(ofnA->lpstrFilter, 0); if ((ofnA->lpstrCustomFilter) && (*(ofnA->lpstrCustomFilter))) ofnW->lpstrCustomFilter = FD31_MapStringPairsToW(ofnA->lpstrCustomFilter, ofnA->nMaxCustFilter); ofnW->nMaxCustFilter = ofnA->nMaxCustFilter; ofnW->nFilterIndex = ofnA->nFilterIndex; ofnW->nMaxFile = ofnA->nMaxFile; ofnW->lpstrFile = FD31_DupToW(ofnA->lpstrFile, ofnW->nMaxFile); ofnW->nMaxFileTitle = ofnA->nMaxFileTitle; ofnW->lpstrFileTitle = FD31_DupToW(ofnA->lpstrFileTitle, ofnW->nMaxFileTitle); if (ofnA->lpstrInitialDir) { RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrInitialDir); ofnW->lpstrInitialDir = usBuffer.Buffer; } if (ofnA->lpstrTitle) { RtlCreateUnicodeStringFromAsciiz (&usBuffer, ofnA->lpstrTitle); ofnW->lpstrTitle = usBuffer.Buffer; } else { WCHAR buf[16]; LPWSTR title_tmp; int len; LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS, buf, sizeof(buf)/sizeof(WCHAR)); len = lstrlenW(buf)+1; title_tmp = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); memcpy(title_tmp, buf, len * sizeof(WCHAR)); ofnW->lpstrTitle = title_tmp; } ofnW->Flags = ofnA->Flags; ofnW->nFileOffset = ofnA->nFileOffset; ofnW->nFileExtension = ofnA->nFileExtension; ofnW->lpstrDefExt = FD31_DupToW(ofnA->lpstrDefExt, 3); if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName)) { if (HIWORD(ofnA->lpTemplateName)) { RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpTemplateName); ofnW->lpTemplateName = usBuffer.Buffer; } else /* numbered resource */ ofnW->lpTemplateName = (LPCWSTR) ofnA->lpTemplateName; } }
/* * @implemented */ BOOL WINAPI ObjectOpenAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, LPSTR ObjectTypeName, LPSTR ObjectName, PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess, DWORD GrantedAccess, PPRIVILEGE_SET Privileges, BOOL ObjectCreation, BOOL AccessGranted, LPBOOL GenerateOnClose) { UNICODE_STRING SubsystemNameU; UNICODE_STRING ObjectTypeNameU; UNICODE_STRING ObjectNameU; NTSTATUS Status; RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, (PCHAR)SubsystemName); RtlCreateUnicodeStringFromAsciiz(&ObjectTypeNameU, (PCHAR)ObjectTypeName); RtlCreateUnicodeStringFromAsciiz(&ObjectNameU, (PCHAR)ObjectName); Status = NtOpenObjectAuditAlarm(&SubsystemNameU, HandleId, &ObjectTypeNameU, &ObjectNameU, pSecurityDescriptor, ClientToken, DesiredAccess, GrantedAccess, Privileges, ObjectCreation, AccessGranted, (PBOOLEAN)GenerateOnClose); RtlFreeUnicodeString(&SubsystemNameU); RtlFreeUnicodeString(&ObjectTypeNameU); RtlFreeUnicodeString(&ObjectNameU); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } return TRUE; }
/****************************************************************************** * RegisterEventSourceA [ADVAPI32.@] * * Returns a registered handle to an event log. * * PARAMS * lpUNCServerName [I] UNC name of the source server. * lpSourceName [I] Specifies the name of the event source to retrieve. * * RETURNS * Success: Handle to the event log. * Failure: NULL. Returns ERROR_INVALID_HANDLE if lpSourceName specifies the * Security event log. */ HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName ) { UNICODE_STRING lpUNCServerNameW; UNICODE_STRING lpSourceNameW; HANDLE ret; FIXME("(%s,%s): stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpSourceName)); RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName); RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName); ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer); RtlFreeUnicodeString (&lpUNCServerNameW); RtlFreeUnicodeString (&lpSourceNameW); return ret; }
/* * @implemented */ HWINSTA WINAPI CreateWindowStationA(LPCSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) { UNICODE_STRING WindowStationNameU; HWINSTA hWinSta; if (lpwinsta) { /* After conversion, the buffer is zero-terminated */ RtlCreateUnicodeStringFromAsciiz(&WindowStationNameU, lpwinsta); } else { RtlInitUnicodeString(&WindowStationNameU, NULL); } hWinSta = CreateWindowStationW(WindowStationNameU.Buffer, dwReserved, dwDesiredAccess, lpsa); /* Free the string, if it was allocated */ if (lpwinsta) RtlFreeUnicodeString(&WindowStationNameU); return hWinSta; }
/****************************************************************************** * ReportEventA [ADVAPI32.@] * * Writes an entry at the end of an event log. * * PARAMS * hEventLog [I] Handle of an event log. * wType [I] See MSDN doc. * wCategory [I] Event category. * dwEventID [I] Event identifier. * lpUserSid [I] Current user's security identifier. * wNumStrings [I] Number of insert strings in lpStrings. * dwDataSize [I] Size of event-specific raw data to write. * lpStrings [I] Buffer containing an array of string to be merged. * lpRawData [I] Buffer containing the binary data. * * RETURNS * Success: nonzero. Entry was written to the log. * Failure: zero. * * NOTES * The ReportEvent function adds the time, the entry's length, and the * offsets before storing the entry in the log. If lpUserSid != NULL, the * username is also logged. */ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID, PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData) { LPWSTR *wideStrArray; UNICODE_STRING str; UINT i; BOOL ret; FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%p,%p): stub\n", hEventLog, wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData); if (wNumStrings == 0) return TRUE; if (!lpStrings) return TRUE; wideStrArray = heap_alloc(sizeof(LPWSTR) * wNumStrings); for (i = 0; i < wNumStrings; i++) { RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]); wideStrArray[i] = str.Buffer; } ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData); for (i = 0; i < wNumStrings; i++) heap_free( wideStrArray[i] ); heap_free(wideStrArray); return ret; }
/* * @implemented */ BOOL WINAPI ObjectDeleteAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, BOOL GenerateOnClose) { UNICODE_STRING Name; NTSTATUS Status; Status = RtlCreateUnicodeStringFromAsciiz(&Name, (PCHAR)SubsystemName); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } Status = NtDeleteObjectAuditAlarm(&Name, HandleId, GenerateOnClose); RtlFreeUnicodeString(&Name); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } return TRUE; }
/* * @implemented */ BOOL WINAPI ObjectPrivilegeAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, HANDLE ClientToken, DWORD DesiredAccess, PPRIVILEGE_SET Privileges, BOOL AccessGranted) { UNICODE_STRING SubsystemNameU; NTSTATUS Status; RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, (PCHAR)SubsystemName); Status = NtPrivilegeObjectAuditAlarm(&SubsystemNameU, HandleId, ClientToken, DesiredAccess, Privileges, AccessGranted); RtlFreeUnicodeString (&SubsystemNameU); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } return TRUE; }
NTSTATUS RtlCliSetCurrentDirectory(PCHAR Directory) { WCHAR buf[MAX_PATH]; UNICODE_STRING us; if (NULL == Directory) { return STATUS_UNSUCCESSFUL; } // Full path contains at least two symbols, the second is ':' if (strnlen(Directory, MAX_PATH) >= 2 && Directory[1] == ':') { RtlCreateUnicodeStringFromAsciiz(&us, Directory); RtlSetCurrentDirectory_U(&us); RtlFreeUnicodeString(&us); return STATUS_SUCCESS; } GetFullPath(Directory, buf, TRUE); RtlInitUnicodeString(&us, buf); RtlSetCurrentDirectory_U(&us); RtlFreeUnicodeString(&us); return STATUS_SUCCESS; }
/*********************************************************************** * GetEnvironmentVariableA (KERNEL32.@) */ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size ) { UNICODE_STRING us_name; PWSTR valueW; DWORD ret; if (!name || !*name) { SetLastError(ERROR_ENVVAR_NOT_FOUND); return 0; } if (!(valueW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)))) return 0; RtlCreateUnicodeStringFromAsciiz( &us_name, name ); SetLastError(0); ret = GetEnvironmentVariableW( us_name.Buffer, valueW, size); if (ret && ret < size) { WideCharToMultiByte( CP_ACP, 0, valueW, ret + 1, value, size, NULL, NULL ); } /* this is needed to tell, with 0 as a return value, the difference between: * - an error (GetLastError() != 0) * - returning an empty string (in this case, we need to update the buffer) */ if (ret == 0 && size && GetLastError() == 0) value[0] = '\0'; RtlFreeUnicodeString( &us_name ); HeapFree(GetProcessHeap(), 0, valueW); return ret; }
/* * @implemented */ HWINSTA WINAPI OpenWindowStationA(LPCSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { UNICODE_STRING WindowStationNameU; HWINSTA hWinSta; if (lpszWinSta) { /* After conversion, the buffer is zero-terminated */ RtlCreateUnicodeStringFromAsciiz(&WindowStationNameU, lpszWinSta); } else { RtlInitUnicodeString(&WindowStationNameU, NULL); } hWinSta = OpenWindowStationW(WindowStationNameU.Buffer, fInherit, dwDesiredAccess); /* Free the string, if it was allocated */ if (lpszWinSta) RtlFreeUnicodeString(&WindowStationNameU); return hWinSta; }
/*********************************************************************** * EnumDisplayDevicesA (USER32.@) */ BOOL WINAPI EnumDisplayDevicesA( LPCSTR lpDevice, DWORD i, LPDISPLAY_DEVICEA lpDispDev, DWORD dwFlags ) { UNICODE_STRING deviceW; DISPLAY_DEVICEW ddW; BOOL ret; if(lpDevice) RtlCreateUnicodeStringFromAsciiz(&deviceW, lpDevice); else deviceW.Buffer = NULL; ddW.cb = sizeof(ddW); ret = EnumDisplayDevicesW(deviceW.Buffer, i, &ddW, dwFlags); RtlFreeUnicodeString(&deviceW); if(!ret) return ret; WideCharToMultiByte(CP_ACP, 0, ddW.DeviceName, -1, lpDispDev->DeviceName, sizeof(lpDispDev->DeviceName), NULL, NULL); WideCharToMultiByte(CP_ACP, 0, ddW.DeviceString, -1, lpDispDev->DeviceString, sizeof(lpDispDev->DeviceString), NULL, NULL); lpDispDev->StateFlags = ddW.StateFlags; if(lpDispDev->cb >= offsetof(DISPLAY_DEVICEA, DeviceID) + sizeof(lpDispDev->DeviceID)) WideCharToMultiByte(CP_ACP, 0, ddW.DeviceID, -1, lpDispDev->DeviceID, sizeof(lpDispDev->DeviceID), NULL, NULL); if(lpDispDev->cb >= offsetof(DISPLAY_DEVICEA, DeviceKey) + sizeof(lpDispDev->DeviceKey)) WideCharToMultiByte(CP_ACP, 0, ddW.DeviceKey, -1, lpDispDev->DeviceKey, sizeof(lpDispDev->DeviceKey), NULL, NULL); return TRUE; }
/* * @implemented */ UINT WINAPI RegisterClipboardFormatA(LPCSTR lpszFormat) { UINT ret = 0; UNICODE_STRING usFormat = {0}; if (lpszFormat == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } /* check for "" */ if (*lpszFormat == 0) //NULL { SetLastError(ERROR_INVALID_NAME); return 0; } ret = RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat); if (ret) { ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR) RtlFreeUnicodeString(&usFormat); } return ret; }
/* * @implemented */ HDESK WINAPI OpenDesktopA( LPCSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { UNICODE_STRING DesktopNameU; HDESK hDesktop; if (lpszDesktop) { /* After conversion, the buffer is zero-terminated */ RtlCreateUnicodeStringFromAsciiz(&DesktopNameU, lpszDesktop); } else { RtlInitUnicodeString(&DesktopNameU, NULL); } hDesktop = OpenDesktopW(DesktopNameU.Buffer, dwFlags, fInherit, dwDesiredAccess); /* Free the string, if it was allocated */ if (lpszDesktop) RtlFreeUnicodeString(&DesktopNameU); return hDesktop; }
LONG WINAPI SCardAddReaderToGroupA(SCARDCONTEXT context, LPCSTR reader, LPCSTR group) { LONG retval; UNICODE_STRING readerW, groupW; if(reader) RtlCreateUnicodeStringFromAsciiz(&readerW,reader); else readerW.Buffer = NULL; if(group) RtlCreateUnicodeStringFromAsciiz(&groupW,group); else groupW.Buffer = NULL; retval = SCardAddReaderToGroupW(context, readerW.Buffer, groupW.Buffer); RtlFreeUnicodeString(&readerW); RtlFreeUnicodeString(&groupW); return retval; }
BOOL WINAPI DeleteItemA(LPCSTR lpGroupName, /* Optional */ BOOL bCommonGroup, LPCSTR lpItemName, BOOL bDeleteGroup) { UNICODE_STRING GroupName; UNICODE_STRING ItemName; BOOL bResult; if (lpGroupName != NULL) { if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, (LPSTR)lpGroupName)) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } } if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, (LPSTR)lpItemName)) { if (lpGroupName != NULL) { RtlFreeUnicodeString(&GroupName); } SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } bResult = DeleteItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL, bCommonGroup, ItemName.Buffer, bDeleteGroup); RtlFreeUnicodeString(&ItemName); if (lpGroupName != NULL) { RtlFreeUnicodeString(&GroupName); } return bResult; }
BOOL WINAPI DeleteProfileA(LPCSTR lpSidString, LPCSTR lpProfilePath, LPCSTR lpComputerName) { BOOL bResult; UNICODE_STRING SidString, ProfilePath, ComputerName; DPRINT("DeleteProfileA() called\n"); /* Conversion to UNICODE */ if (lpSidString) RtlCreateUnicodeStringFromAsciiz(&SidString, (LPSTR)lpSidString); if (lpProfilePath) RtlCreateUnicodeStringFromAsciiz(&ProfilePath, (LPSTR)lpProfilePath); if (lpComputerName) RtlCreateUnicodeStringFromAsciiz(&ComputerName, (LPSTR)lpComputerName); /* Call the UNICODE function */ bResult = DeleteProfileW(SidString.Buffer, ProfilePath.Buffer, ComputerName.Buffer); /* Memory cleanup */ if (lpSidString) RtlFreeUnicodeString(&SidString); if (lpProfilePath) RtlFreeUnicodeString(&ProfilePath); if (lpComputerName) RtlFreeUnicodeString(&ComputerName); return bResult; }