208 if (et[
i].NameIsString)
212 if (newlen + 1 >
len)
258 if (et[
i].NameIsString)
261 if (
str->Length + 1 >
len)
315 if (et[
i].NameIsString)
319 if (newlen + 1 >
len)
387 if (et[
i].NameIsString)
390 if (
str->Length + 1 >
len)
539 if (!hRsrc)
return 0;
570 if (!hRsrc)
return 0;
618 return (
a <
b ) ? -1 : 1;
696 BOOL overwrite_existing )
701 TRACE(
"%p %s %s %p %d\n", updates,
729 if (!overwrite_existing)
752 resdata->
lang = Language;
757 resdata->
lpData = &resdata[1];
798 if (mapping_size<
sizeof (*
dos))
834 return (
void*) ((
BYTE*)
nt + section_ofs);
845 DWORD mapping_size, num_sections = 0;
867 TRACE(
"resources: %08x %08x\n",
906 DWORD num_sections = 0;
913 for (
i=num_sections-1;
i>=0;
i--)
944 if (!
entry->NameIsString)
950 s[
string->Length] = 0;
965 TRACE(
"version (%d.%d) %d named %d id entries\n",
966 root->MajorVersion,
root->MinorVersion,
root->NumberOfNamedEntries,
root->NumberOfIdEntries);
968 for (
i = 0;
i<
root->NumberOfNamedEntries +
root->NumberOfIdEntries;
i++)
1020 DWORD num_sections = 0,
i;
1030 for (
i=0;
i<num_sections;
i++)
1034 if (
i == num_sections)
1038 if (sec[
i].PointerToRawData > mapping_size ||
1039 (sec[
i].PointerToRawData + sec[
i].SizeOfRawData) > mapping_size)
1042 TRACE(
"found .rsrc at %08x, size %08x\n", sec[
i].PointerToRawData, sec[
i].SizeOfRawData);
1055 DWORD page_attr, perm;
1104 mi->read_write =
rw;
1129 ERR(
"failed to set file size to %08x\n", new_size );
1133 mi->size = new_size;
1142 DWORD num_types = 0,
num_names = 0, num_langs = 0, strings_size = 0, data_size = 0;
1144 memset( si, 0,
sizeof *si );
1162 data_size += (
data->cbData + 3) & ~3;
1187 TRACE(
"names %08x langs %08x data entries %08x strings %08x data %08x total %08x\n",
1194 static const BYTE pad[] = {
1195 'P',
'A',
'D',
'D',
'I',
'N',
'G',
'X',
'X',
'P',
'A',
'D',
'D',
'I',
'N',
'G' };
1198 for (
i = 0;
i <
size /
sizeof pad;
i++ )
1199 memcpy( &res_base[
i*
sizeof pad], pad,
sizeof pad );
1200 memcpy( &res_base[
i*
sizeof pad], pad,
size%
sizeof pad );
1209 TRACE(
"%p %p %p %08x\n", updates,
base, si, rva );
1216 root->MajorVersion = 4;
1224 memset( e1, 0,
sizeof *e1 );
1230 root->NumberOfNamedEntries++;
1242 root->NumberOfIdEntries++;
1250 memset( namedir, 0,
sizeof *namedir );
1260 memset( e2, 0,
sizeof *e2 );
1286 memset( langdir, 0,
sizeof *langdir );
1297 memset( e3, 0,
sizeof *e3 );
1306 memset( de, 0,
sizeof *de );
1345 DWORD i, num_sections = 0;
1356 for (
i=0;
i<num_sections;
i++)
1360 if (
i == num_sections)
1368 DWORD i, sz = 0, num_sections = 0;
1373 for (
i=0;
i<num_sections;
i++)
1375 sz +=
s[
i].SizeOfRawData;
1377 TRACE(
"size = %08x\n", sz);
1384 static const WCHAR prefix[] = {
'r',
'e',
's',
'u',0 };
1394 DWORD PeSectionAlignment, PeFileAlignment, PeSizeOfImage;
1418 ERR(
"failed to read existing resources\n");
1442 if ((
LONG)PeSectionAlignment <= 0)
1444 ERR(
"invalid section alignment %08x\n", PeSectionAlignment);
1448 if ((
LONG)PeFileAlignment <= 0)
1450 ERR(
"invalid file alignment %08x\n", PeFileAlignment);
1463 sec += num_sections;
1466 memset( sec, 0,
sizeof *sec );
1474 sec->
PointerToRawData = write_map->size + (-write_map->size) % PeFileAlignment;
1484 section_size += (-section_size) % PeFileAlignment;
1486 TRACE(
"requires %08x (%08x) bytes\n", res_size.
total_size, section_size );
1491 DWORD old_size = write_map->size;
1494 int rva_delta = virtual_section_size -
1502 BOOL resize_after = mapping_size < old_size && !rsrc_is_last;
1504 TRACE(
"file size %08x -> %08x\n", old_size, mapping_size);
1515 ERR(
"couldn't get NT header\n");
1529 DWORD i, num_sections = 0;
1531 memmove( (
char*)write_map->base + tail_start + delta, (
char*)write_map->base + tail_start, old_size - tail_start );
1535 for (
i=0;
i<num_sections;
i++)
1539 s[
i].PointerToRawData += delta;
1540 s[
i].VirtualAddress += rva_delta;
1552 ERR(
"couldn't get NT header\n");
1676 TRACE(
"%p %d\n", hUpdate, fDiscard);
1712 TRACE(
"%p %s %s %08x %p %d\n", hUpdate,
1718 if (lpData ==
NULL && cbData == 0)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
struct outqueuenode * head
static const WCHAR nameW[]
#define DEBUG_CHANNEL(args)
static void list_remove(struct list_entry *entry)
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
static void list_init(struct list_entry *head)
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ERROR_INVALID_PARAMETER
#define INVALID_HANDLE_VALUE
#define CreateFileMappingW(a, b, c, d, e, f)
#define HeapFree(x, y, z)
#define WideCharToMultiByte
#define __EXCEPT_PAGE_FAULT
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
BOOL WINAPI SetEndOfFile(HANDLE hFile)
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
BOOL WINAPI FreeResource(HGLOBAL handle)
static void res_write_padding(BYTE *res_base, DWORD size)
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
BOOL WINAPI EnumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpfun, LONG_PTR lparam)
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
BOOL WINAPI UpdateResourceW(HANDLE hUpdate, LPCWSTR lpType, LPCWSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData)
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
static LPWSTR res_strdupW(LPCWSTR str)
static BOOL enumerate_mapped_resources(QUEUEDUPDATES *updates, void *base, DWORD mapping_size, const IMAGE_RESOURCE_DIRECTORY *root)
static LPWSTR resource_dup_string(const IMAGE_RESOURCE_DIRECTORY *root, const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry)
static NTSTATUS get_res_nameW(LPCWSTR name, UNICODE_STRING *str)
static struct mapping_info * create_mapping(LPCWSTR name, BOOL rw)
static BOOL map_file_into_memory(struct mapping_info *mi)
BOOL WINAPI UpdateResourceA(HANDLE hUpdate, LPCSTR lpType, LPCSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData)
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
BOOL WINAPI EndUpdateResourceW(HANDLE hUpdate, BOOL fDiscard)
static BOOL write_raw_resources(QUEUEDUPDATES *updates)
static void get_resource_sizes(QUEUEDUPDATES *updates, struct resource_size_info *si)
static BOOL write_resources(QUEUEDUPDATES *updates, LPBYTE base, struct resource_size_info *si, DWORD rva)
static BOOL unmap_file_from_memory(struct mapping_info *mi)
static BOOL read_mapped_resources(QUEUEDUPDATES *updates, void *base, DWORD mapping_size)
BOOL WINAPI EnumResourceTypesA(HMODULE hmod, ENUMRESTYPEPROCA lpfun, LONG_PTR lparam)
static void free_resource_directory(struct list *head, int level)
static BOOL update_add_resource(QUEUEDUPDATES *updates, LPCWSTR Type, LPCWSTR Name, LANGID Lang, struct resource_data *resdata, BOOL overwrite_existing)
static HRSRC find_resourceA(HMODULE hModule, LPCSTR type, LPCSTR name, WORD lang)
BOOL WINAPI EnumResourceLanguagesA(HMODULE hmod, LPCSTR type, LPCSTR name, ENUMRESLANGPROCA lpfun, LONG_PTR lparam)
static void destroy_mapping(struct mapping_info *mi)
static int resource_strcmp(LPCWSTR a, LPCWSTR b)
static void add_resource_data_entry(struct list *dir, struct resource_data *resdata)
LPVOID WINAPI LockResource(HGLOBAL handle)
static DWORD get_init_data_size(void *base, DWORD mapping_size)
static struct resource_data * allocate_resource_data(WORD Language, DWORD codepage, LPVOID lpData, DWORD cbData, BOOL copy_data)
BOOL WINAPI EnumResourceNamesA(HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfun, LONG_PTR lparam)
static IMAGE_NT_HEADERS * get_nt_header(void *base, DWORD mapping_size)
static NTSTATUS get_res_nameA(LPCSTR name, UNICODE_STRING *str)
static BOOL resize_mapping(struct mapping_info *mi, DWORD new_size)
static HRSRC find_resourceW(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang)
static BOOL check_pe_exe(HANDLE file, QUEUEDUPDATES *updates)
static const IMAGE_SECTION_HEADER * section_from_rva(void *base, DWORD mapping_size, DWORD rva)
static struct resource_data * find_resource_data(struct list *dir, LANGID lang)
static IMAGE_SECTION_HEADER * get_resource_section(void *base, DWORD mapping_size)
static struct resource_dir_entry * find_resource_dir_entry(struct list *dir, LPCWSTR id)
static void res_free_str(LPWSTR str)
HRSRC WINAPI FindResourceExW(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang)
static void * address_from_rva(void *base, DWORD mapping_size, DWORD rva, DWORD len)
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
HANDLE WINAPI BeginUpdateResourceW(LPCWSTR pFileName, BOOL bDeleteExistingResources)
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
HRSRC WINAPI FindResourceExA(HMODULE hModule, LPCSTR type, LPCSTR name, WORD lang)
BOOL WINAPI EnumResourceLanguagesW(HMODULE hmod, LPCWSTR type, LPCWSTR name, ENUMRESLANGPROCW lpfun, LONG_PTR lparam)
static IMAGE_SECTION_HEADER * get_section_header(void *base, DWORD mapping_size, DWORD *num_sections)
static void add_resource_dir_entry(struct list *dir, struct resource_dir_entry *resdir)
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
static const WCHAR typeW[]
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLsizei const GLchar *const * strings
GLboolean GLboolean GLboolean b
GLenum GLenum GLenum GLenum mapping
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSTATUS NTAPI LdrAccessResource(_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
NTSTATUS NTAPI LdrFindResourceDirectory_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DIRECTORY *ResourceDirectory)
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
static PEXPLICIT_ACCESSW *static HMODULE hmod
unsigned __int3264 UINT_PTR
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI NTSTATUS NTAPI RtlCharToInteger(PCSZ String, ULONG Base, PULONG Value)
#define IMAGE_SCN_CNT_INITIALIZED_DATA
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
#define IMAGE_SCN_MEM_READ
#define STATUS_ACCESS_VIOLATION
struct _IMAGE_RESOURCE_DIRECTORY_ENTRY IMAGE_RESOURCE_DIRECTORY_ENTRY
#define IMAGE_NT_SIGNATURE
struct _IMAGE_RESOURCE_DIRECTORY IMAGE_RESOURCE_DIRECTORY
#define IMAGE_DOS_SIGNATURE
struct _IMAGE_RESOURCE_DATA_ENTRY IMAGE_RESOURCE_DATA_ENTRY
#define IMAGE_DIRECTORY_ENTRY_RESOURCE
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
__WINE_SERVER_LIST_INLINE void list_add_before(struct list *elem, struct list *to_add)
BOOL bDeleteExistingResources
WORD NumberOfNamedEntries
#define FIELD_OFFSET(t, f)
#define STATUS_INVALID_PARAMETER
static const WCHAR lang[]
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
BOOL(CALLBACK * ENUMRESNAMEPROCW)(HMODULE, LPCWSTR, LPWSTR, LONG_PTR)
BOOL(CALLBACK * ENUMRESLANGPROCA)(HMODULE, LPCSTR, LPCSTR, WORD, LONG_PTR)
BOOL(CALLBACK * ENUMRESTYPEPROCA)(HMODULE, LPSTR, LONG_PTR)
BOOL(CALLBACK * ENUMRESNAMEPROCA)(HMODULE, LPCSTR, LPSTR, LONG_PTR)
BOOL(CALLBACK * ENUMRESLANGPROCW)(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG_PTR)
BOOL(CALLBACK * ENUMRESTYPEPROCW)(HMODULE, LPWSTR, LONG_PTR)
#define IS_INTRESOURCE(i)
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList