ReactOS 0.4.16-dev-2216-ga08d639
resource.c File Reference
#include <windows.h>
#include <stdio.h>
#include "wine/test.h"
Include dependency graph for resource.c:

Go to the source code of this file.

Classes

struct  _sec_build
 
struct  _sec_verify
 
struct  _sec_variants
 
struct  QUEUEDUPDATES
 
struct  mui_res
 

Typedefs

typedef struct _sec_build sec_build
 
typedef struct _sec_verify sec_verify
 

Enumerations

enum  constants { page_size = 0x1000 , rva_rsrc_start = page_size * 3 , max_sections = 3 }
 

Functions

static int build_exe (const sec_build *sec_descr)
 
static void update_missing_exe (void)
 
static void update_empty_exe (void)
 
static void update_resources_none (void)
 
static void update_resources_delete (void)
 
static void update_resources_version (void)
 
static void update_resources_bigdata (void)
 
static void update_resources_name (void)
 
static void check_exe (const sec_verify *verify)
 
static void test_find_resource (void)
 
static void test_internal_structure (void)
 
static void create_test_dll (const WCHAR *name)
 
static void test_mui (void)
 
 START_TEST (resource)
 

Variables

static const char filename [] = "test_.exe"
 
static const WCHAR filenameW [] = {'t','e','s','t','_','.','e','x','e',0}
 
static DWORD GLE
 
static const IMAGE_SECTION_HEADER sh_rodata_1
 
static const IMAGE_SECTION_HEADER sh_rodata_2
 
static const IMAGE_SECTION_HEADER sh_rsrc_1
 
static const IMAGE_SECTION_HEADER sh_rsrc_2
 
static const IMAGE_SECTION_HEADER sh_rsrc_3
 
static const IMAGE_SECTION_HEADER sh_rsrc_4
 
static const IMAGE_SECTION_HEADER sh_rsrc_5
 
static const IMAGE_SECTION_HEADER sh_rsrc_6
 
static const IMAGE_SECTION_HEADER sh_junk
 
static const IMAGE_SECTION_HEADER sh_junk_2
 
static const struct _sec_variants sec_variants []
 
struct {
   IMAGE_DOS_HEADER   dos
 
   IMAGE_NT_HEADERS   nt
 
   IMAGE_SECTION_HEADER   section
 
dll_image
 
static struct mui_res ln_mui_res
 
static struct mui_res en_mui_res
 

Typedef Documentation

◆ sec_build

◆ sec_verify

Enumeration Type Documentation

◆ constants

Enumerator
page_size 
rva_rsrc_start 
max_sections 

Definition at line 30 of file resource.c.

30 {
31 page_size = 0x1000,
33 max_sections = 3
34};
@ max_sections
Definition: resource.c:33
@ rva_rsrc_start
Definition: resource.c:32
@ page_size
Definition: resource.c:31

Function Documentation

◆ build_exe()

static int build_exe ( const sec_build sec_descr)
static

Definition at line 162 of file resource.c.

163{
168 HANDLE file;
169 DWORD written, i, file_size;
171
172 memset( page, 0, sizeof page );
173
174 dos = (void*) page;
176 dos->e_lfanew = sizeof *dos;
177
178 nt = (void*) &dos[1];
179
185
186 opt = &nt->OptionalHeader;
187
189 opt->MajorLinkerVersion = 1;
190 opt->BaseOfCode = 0x10;
191 opt->ImageBase = 0x10000000;
193 opt->MajorImageVersion = 1;
194 opt->MajorSubsystemVersion = 4;
195 opt->SizeOfHeaders = sizeof *dos + sizeof *nt + sizeof *sec * 2;
196 opt->SizeOfImage = page_size;
198
199 /* if SectionAlignment and File alignment are not specified */
200 /* UpdateResource fails trying to create a huge temporary file */
203
207
208 sec = (void*) &nt[1];
209
210 file_size = 0;
211 for ( i = 0; i < max_sections; i++ )
212 if ( sec_descr->sect_in[i] )
213 {
214 DWORD virt_end_of_section = sec_descr->sect_in[i]->Misc.VirtualSize +
215 sec_descr->sect_in[i]->VirtualAddress;
216 DWORD phys_end_of_section = sec_descr->sect_in[i]->SizeOfRawData +
217 sec_descr->sect_in[i]->PointerToRawData;
218 memcpy( sec + nt->FileHeader.NumberOfSections, sec_descr->sect_in[i],
219 sizeof(sec[0]) );
221 if ( opt->SizeOfImage < virt_end_of_section )
222 opt->SizeOfImage = virt_end_of_section;
223 if ( file_size < phys_end_of_section )
224 file_size = phys_end_of_section;
225 }
226
228 ok (file != INVALID_HANDLE_VALUE, "failed to create file\n");
229
230 /* write out the header */
231 WriteFile( file, page, sizeof page, &written, NULL );
232
233 /* write out zeroed pages for sections */
234 memset( page, 0, sizeof page );
235 for ( i = page_size; i < file_size; i += page_size )
236 {
238 WriteFile( file, page, size, &written, NULL );
239 }
240
241 CloseHandle( file );
242
243 return 0;
244}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
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
Definition: glfuncs.h:248
const char * filename
Definition: ioapi.h:137
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
IMAGE_NT_HEADERS nt
Definition: resource.c:526
IMAGE_DOS_HEADER dos
Definition: resource.c:525
#define min(a, b)
Definition: monoChain.cc:55
#define GENERIC_WRITE
Definition: nt_native.h:90
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
Definition: ntimage.h:438
#define IMAGE_NT_OPTIONAL_HDR_MAGIC
Definition: ntimage.h:387
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_FILE_DLL
Definition: pedump.c:169
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
static unsigned int file_size
Definition: regtests2xml.c:47
#define memset(x, y, z)
Definition: compat.h:39
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
WORD MajorOperatingSystemVersion
Definition: ntddk_ex.h:160
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
union _IMAGE_SECTION_HEADER::@1702 Misc
DWORD PointerToRawData
Definition: pedump.c:290
const IMAGE_SECTION_HEADER * sect_in[max_sections]
Definition: resource.c:108
Definition: fci.c:127
Definition: module.h:576
#define IMAGE_FILE_RESOURCE_DIRECTORY
Definition: winnt_old.h:670
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ check_exe()

static void check_exe ( const sec_verify verify)
static

Definition at line 393 of file resource.c.

394{
395 int i;
402 DWORD length, sec_count = 0;
403
405 ok (file != INVALID_HANDLE_VALUE, "failed to create file (%ld)\n", GetLastError());
406
408 ok( length >= verify->length, "file size wrong\n");
409
411 ok (mapping != NULL, "failed to create file\n");
412
414 ok( dos != NULL, "failed to map file\n");
415
416 if (!dos)
417 goto end;
418
419 nt = (void*) ((BYTE*) dos + dos->e_lfanew);
420 opt = &nt->OptionalHeader;
421 sec = (void*) &nt[1];
422
423 for(i = 0; i < max_sections; i++)
424 if (verify->sect_out[i])
425 {
426 ok( !memcmp(&verify->sect_out[i]->Name, &sec[sec_count].Name, 8), "section %ld name wrong\n", sec_count);
427 ok( verify->sect_out[i]->VirtualAddress == sec[sec_count].VirtualAddress, "section %ld vaddr wrong\n", sec_count);
428 ok( verify->sect_out[i]->SizeOfRawData <= sec[sec_count].SizeOfRawData, "section %ld SizeOfRawData wrong (%ld vs %ld)\n", sec_count, verify->sect_out[i]->SizeOfRawData ,sec[sec_count].SizeOfRawData);
429 ok( verify->sect_out[i]->PointerToRawData == sec[sec_count].PointerToRawData, "section %ld PointerToRawData wrong\n", sec_count);
430 ok( verify->sect_out[i]->Characteristics == sec[sec_count].Characteristics , "section %ld characteristics wrong\n", sec_count);
431 sec_count++;
432 }
433
434 ok( nt->FileHeader.NumberOfSections == sec_count, "number of sections wrong\n" );
435
436 if (verify->rsrc_section >= 0 && verify->rsrc_section < nt->FileHeader.NumberOfSections)
437 {
438 dir = (void*) ((BYTE*) dos + sec[verify->rsrc_section].VirtualAddress);
439
440 ok( dir->Characteristics == 0, "Characteristics wrong\n");
441 ok( dir->TimeDateStamp == 0, "TimeDateStamp wrong %lu\n", dir->TimeDateStamp);
442 ok( dir->MajorVersion == 4, "MajorVersion wrong\n");
443 ok( dir->MinorVersion == 0, "MinorVersion wrong\n");
444
445 ok( dir->NumberOfNamedEntries == verify->NumberOfNamedEntries, "NumberOfNamedEntries should be %ld instead of %d\n",
446 verify->NumberOfNamedEntries, dir->NumberOfNamedEntries);
447 ok( dir->NumberOfIdEntries == verify->NumberOfIdEntries, "NumberOfIdEntries should be %ld instead of %d\n",
448 verify->NumberOfIdEntries, dir->NumberOfIdEntries);
449
450 ok(opt->DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY].VirtualAddress == sec[verify->rsrc_section].VirtualAddress,
451 "VirtualAddress in optional header should be %ld instead of %ld\n",
453 }
454
455end:
457
459
460 CloseHandle( file );
461}
unsigned int dir
Definition: maze.c:112
#define PAGE_READONLY
Definition: compat.h:138
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
GLuint GLuint end
Definition: gl.h:1545
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
BYTE Name[IMAGE_SIZEOF_SHORT_NAME]
Definition: pedump.c:281
int rsrc_section
Definition: resource.c:115
DWORD NumberOfIdEntries
Definition: resource.c:116
const IMAGE_SECTION_HEADER * sect_out[max_sections]
Definition: resource.c:113
DWORD NumberOfNamedEntries
Definition: resource.c:116
DWORD length
Definition: resource.c:114
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ create_test_dll()

static void create_test_dll ( const WCHAR name)
static

Definition at line 592 of file resource.c.

593{
594 DWORD dummy;
596
597 ok( handle != INVALID_HANDLE_VALUE, "failed to create file err %lu\n", GetLastError() );
598 WriteFile( handle, &dll_image, sizeof(dll_image), &dummy, NULL );
599 SetFilePointer( handle, dll_image.nt.OptionalHeader.SizeOfImage, NULL, FILE_BEGIN );
602}
#define FILE_BEGIN
Definition: compat.h:761
#define SetFilePointer
Definition: compat.h:743
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
static const struct @1822 dll_image
Definition: name.c:39

Referenced by test_mui().

◆ START_TEST()

START_TEST ( resource  )

Definition at line 842 of file resource.c.

843{
844 DWORD i;
845
848
850 {
851 win_skip("Resource calls are not implemented\n");
852 return;
853 }
854
856
857 for(i=0; i < ARRAY_SIZE(sec_variants); i++)
858 {
859 const struct _sec_variants *sec = &sec_variants[i];
860 build_exe( &sec->build );
863 check_exe( &sec->chk_none );
865 check_exe( &sec->chk_delete );
867 check_exe( &sec->chk_version );
869 check_exe( &sec->chk_bigdata );
872 }
874 test_mui();
875}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define win_skip
Definition: minitest.h:67
static void update_resources_version(void)
Definition: resource.c:311
static void update_missing_exe(void)
Definition: resource.c:246
static DWORD GLE
Definition: resource.c:28
static int build_exe(const sec_build *sec_descr)
Definition: resource.c:162
static void update_empty_exe(void)
Definition: resource.c:256
static void update_resources_none(void)
Definition: resource.c:287
static void update_resources_delete(void)
Definition: resource.c:299
static void update_resources_bigdata(void)
Definition: resource.c:341
static const struct _sec_variants sec_variants[]
static void test_mui(void)
Definition: resource.c:657
static void test_internal_structure(void)
Definition: resource.c:505
static void test_find_resource(void)
Definition: resource.c:463
static void update_resources_name(void)
Definition: resource.c:361
static void check_exe(const sec_verify *verify)
Definition: resource.c:393
sec_verify chk_bigdata
Definition: resource.c:122
sec_build build
Definition: resource.c:121
sec_verify chk_none
Definition: resource.c:122
sec_verify chk_version
Definition: resource.c:122
sec_verify chk_delete
Definition: resource.c:122

◆ test_find_resource()

static void test_find_resource ( void  )
static

Definition at line 463 of file resource.c.

464{
465 HRSRC rsrc;
466
468 ok( rsrc != 0, "resource not found\n" );
471 ok( rsrc != 0, "resource not found\n" );
474 ok( rsrc != 0, "resource not found\n" );
475
476 SetLastError( 0xdeadbeef );
478 ok( !rsrc, "resource found\n" );
479 ok( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "wrong error %lu\n", GetLastError() );
480
481 SetLastError( 0xdeadbeef );
483 ok( !rsrc, "resource found\n" );
484 ok( GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "wrong error %lu\n", GetLastError() );
485
486 SetLastError( 0xdeadbeef );
489 ok( !rsrc, "resource found\n" );
490 ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %lu\n", GetLastError() );
491
492 SetLastError( 0xdeadbeef );
495 ok( !rsrc, "resource found\n" );
496 ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %lu\n", GetLastError() );
497}
#define SetLastError(x)
Definition: compat.h:752
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HRSRC WINAPI FindResourceExW(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang)
Definition: res.c:164
#define RT_MENU
Definition: pedump.c:366
#define RT_DIALOG
Definition: pedump.c:367
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_GERMAN
Definition: nls.h:62
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_NEUTRAL
Definition: nls.h:167
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define LANG_FRENCH
Definition: nls.h:58
#define ERROR_RESOURCE_TYPE_NOT_FOUND
Definition: winerror.h:1477
#define ERROR_RESOURCE_LANG_NOT_FOUND
Definition: winerror.h:1479
#define ERROR_RESOURCE_NAME_NOT_FOUND
Definition: winerror.h:1478
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ test_internal_structure()

static void test_internal_structure ( void  )
static

Definition at line 505 of file resource.c.

506{
507 HANDLE res;
508 QUEUEDUPDATES *res_data;
509 WCHAR *res_filenameW;
510
512 ok( res != NULL, "BeginUpdateResourceW failed\n" );
513 res_data = GlobalLock(res);
514 ok( res_data != NULL, "GlobalLock failed\n" );
515 res_filenameW = GlobalLock( res_data->pFileName );
516 ok( res_filenameW != NULL, "GlobalLock for res_filenameW failed\n" );
517 ok( !lstrcmpW( res_filenameW, filenameW ), "Filename fields do not match\n" );
518 ok( GlobalUnlock( res_filenameW ), "GlobalUnlock res_filenamed failed\n" );
519 ok( GlobalUnlock( res_data ), "GlobalUnlock res_data failed\n" );
520 ok( EndUpdateResourceW( res, TRUE ), "EndUpdateResourceW failed\n");
521}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI EndUpdateResourceW(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1671
HANDLE WINAPI BeginUpdateResourceW(LPCWSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1611
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
GLuint res
Definition: glext.h:9613
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
static const WCHAR filenameW[]
Definition: resource.c:27
LPWSTR pFileName
Definition: res.c:586
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_mui()

static void test_mui ( void  )
static

Definition at line 657 of file resource.c.

658{
659#if defined(__REACTOS__) && DLL_EXPORT_VERSION < 0x600
660 skip("Cannot build test_mui() unless DLL_EXPORT_VERSION >= 0x600.\n");
661#else
662 static const WCHAR ln_dll[] = L"test_mui.dll";
663 static const WCHAR en_dll[] = L"en-US\\test_mui.dll.mui";
664 static const BYTE zeros[16] = { 0 };
665 BYTE buf[1024];
667 const WCHAR *str;
668 DWORD size, *id;
669 HANDLE res;
670 BOOL r;
671
672 size = 0;
673 r = GetFileMUIInfo( 0, ln_dll, NULL, &size);
674 ok( !r, "GetFileMUIInfo succeeded\n" );
675 ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %ld\n", GetLastError() );
676
677 create_test_dll( ln_dll );
678 CreateDirectoryW( L"en-US", NULL );
679 create_test_dll( en_dll );
680
681 size = 0;
682 r = GetFileMUIInfo( 0, ln_dll, NULL, &size );
683 ok( r, "GetFileMUIInfo failed: %ld\n", GetLastError() );
684 ok( size == sizeof(*info), "unexpected size: %ld\n", size );
685
686 memset( buf, 0xfe, sizeof(buf) );
687 size = sizeof(buf);
688 info->dwSize = sizeof(buf);
689 info->dwVersion = 0;
690 r = GetFileMUIInfo( 0, ln_dll, info, &size );
691 ok( !r, "GetFileMUIInfo succeeded\n" );
692 ok( GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %ld\n", GetLastError() );
693 ok( !size, "size = %ld\n", size );
694
695 size = sizeof(buf);
696 info->dwVersion = MUI_FILEINFO_VERSION;
697 r = GetFileMUIInfo( 0, ln_dll, info, &size );
698 ok( r, "GetFileMUIInfo failed: %ld\n", GetLastError() );
699 ok( info->dwSize == sizeof(buf), "dwSize = %ld\n", info->dwSize );
700 ok( info->dwVersion == MUI_FILEINFO_VERSION, "dwVersion = %ld\n", info->dwVersion );
701 ok( info->dwFileType == MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL, "dwFileType = %ld\n", info->dwFileType );
702 ok( !memcmp(info->pChecksum, zeros, sizeof(info->pChecksum)), "pChecksum = %s\n",
703 wine_dbgstr_an((char *)info->pChecksum, sizeof(info->pChecksum)) );
704 ok( !memcmp(info->pServiceChecksum, zeros, sizeof(info->pServiceChecksum)), "pServiceChecksum = %s\n",
705 wine_dbgstr_an((char *)info->pServiceChecksum, sizeof(info->pServiceChecksum)) );
706 ok( !info->dwLanguageNameOffset, "dwLanguageNameOffset = %ld\n", info->dwLanguageNameOffset );
707 ok( !info->dwTypeIDMainSize, "dwTypeIDMainSize = %ld\n", info->dwTypeIDMainSize );
708 ok( !info->dwTypeIDMainOffset, "dwTypeIDMainOffset = %ld\n", info->dwTypeIDMainOffset );
709 ok( !info->dwTypeNameMainOffset, "dwTypeNameMainOffset = %ld\n", info->dwTypeNameMainOffset );
710 ok( !info->dwTypeIDMUISize, "dwTypeIDMUISize = %ld\n", info->dwTypeIDMUISize );
711 ok( !info->dwTypeIDMUIOffset, "dwTypeIDMUIOffset = %ld\n", info->dwTypeIDMUIOffset );
712 ok( !info->dwTypeNameMUIOffset, "dwTypeNameMUIOffset = %ld\n", info->dwTypeNameMUIOffset );
713 ok( !memcmp(info->abBuffer, zeros, sizeof(info->abBuffer)), "abBuffer = %s\n",
714 wine_dbgstr_an((char *)info->abBuffer, sizeof(info->abBuffer)) );
715
716 res = BeginUpdateResourceW( ln_dll, TRUE );
717 ok( res != NULL, "BeginUpdateResourceW failed: %ld\n", GetLastError() );
718 r = UpdateResourceW( res, L"MUI", MAKEINTRESOURCEW(1), 0, &ln_mui_res, 4 );
719 ok( r, "UpdateResource failed: %ld\n", GetLastError() );
721 ok( r, "EndUpdateResourceW failed: %ld\n", GetLastError() );
722
723 size = 0;
724 r = GetFileMUIInfo( MUI_QUERY_TYPE | MUI_QUERY_CHECKSUM | MUI_QUERY_LANGUAGE_NAME
725 | MUI_QUERY_RESOURCE_TYPES, ln_dll, NULL, &size );
726 ok( !r, "GetFileMUIInfo succeeded\n" );
727#if defined(__REACTOS__) && defined(_WIN64)
728 ok( GetLastError() == ERROR_BAD_EXE_FORMAT || GetLastError() == ERROR_INSUFFICIENT_BUFFER /* Vista x64 */, "GetLastError() = %ld\n", GetLastError() );
729#else
730 ok( GetLastError() == ERROR_BAD_EXE_FORMAT, "GetLastError() = %ld\n", GetLastError() );
731#endif
732
733 res = BeginUpdateResourceW( ln_dll, TRUE );
734 ok( res != NULL, "BeginUpdateResourceW failed: %ld\n", GetLastError() );
735 r = UpdateResourceW( res, L"MUI", MAKEINTRESOURCEW(1), 0, &ln_mui_res, sizeof(ln_mui_res) );
736 ok( r, "UpdateResource failed: %ld\n", GetLastError() );
738 ok( r, "EndUpdateResourceW failed: %ld\n", GetLastError() );
739
740 size = 0;
741 r = GetFileMUIInfo( MUI_QUERY_TYPE | MUI_QUERY_CHECKSUM | MUI_QUERY_LANGUAGE_NAME
742 | MUI_QUERY_RESOURCE_TYPES, ln_dll, NULL, &size );
743 ok( !r, "GetFileMUIInfo succeeded\n" );
744 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %ld\n", GetLastError() );
745 ok( size, "size was not set\n" );
746
747 memset( buf, 0xfe, sizeof(buf) );
748 size = sizeof(buf);
749 info->dwSize = sizeof(buf);
750 info->dwVersion = MUI_FILEINFO_VERSION;
751 r = GetFileMUIInfo( MUI_QUERY_TYPE | MUI_QUERY_CHECKSUM | MUI_QUERY_LANGUAGE_NAME
752 | MUI_QUERY_RESOURCE_TYPES, ln_dll, info, &size );
753 ok( r, "GetFileMUIInfo failed: %ld\n", GetLastError() );
754 ok( info->dwSize == sizeof(buf), "dwSize = %ld\n", info->dwSize );
755 ok( info->dwVersion == MUI_FILEINFO_VERSION, "dwVersion = %ld\n", info->dwVersion );
756 ok( info->dwFileType == MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN, "dwFileType = %ld\n", info->dwFileType );
757 ok( info->pChecksum[0] == 'c', "pChecksum = %s\n",
758 wine_dbgstr_an((char *)info->pChecksum, sizeof(info->pChecksum)) );
759 ok( info->pServiceChecksum[0] == 's', "pServiceChecksum = %s\n",
760 wine_dbgstr_an((char *)info->pServiceChecksum, sizeof(info->pServiceChecksum)) );
761 ok( info->dwLanguageNameOffset == 72, "dwLanguageNameOffset = %ld\n", info->dwLanguageNameOffset );
762#if defined(__REACTOS__) && DLL_EXPORT_VERSION >= 0x600
763 if (is_reactos()) {
764 ok(FALSE, "FIXME: These tests crash on ReactOS!\n");
765 } else {
766#endif
767 str = (WCHAR *)(buf + info->dwLanguageNameOffset);
768 ok( !wcscmp(str, L"en-US"), "language name = %s\n", wine_dbgstr_w(str) );
769 ok( info->dwTypeIDMainSize == 1, "dwTypeIDMainSize = %ld\n", info->dwTypeIDMainSize );
770 ok( info->dwTypeIDMainOffset == 84, "dwTypeIDMainOffset = %ld\n", info->dwTypeIDMainOffset );
771 id = (DWORD *)(buf + info->dwTypeIDMainOffset);
772 ok( id[0] == RT_CURSOR, "type ID main[0] = %ld\n", id[0] );
773 ok( info->dwTypeNameMainOffset == 88, "dwTypeNameMainOffset = %ld\n", info->dwTypeNameMainOffset );
774 str = (WCHAR *)(buf + info->dwTypeNameMainOffset);
775 ok( !wcscmp(str, L"MUI"), "type name main[0] = %s\n", wine_dbgstr_w(str) );
776 str += wcslen(str) + 1;
777 ok( !str[0], "string list is not NULL terminated: %s\n", wine_dbgstr_w(str) );
778 ok( info->dwTypeIDMUISize == 1, "dwTypeIDMUISize = %ld\n", info->dwTypeIDMUISize );
779 ok( info->dwTypeIDMUIOffset == 98, "dwTypeIDMUIOffset = %ld\n", info->dwTypeIDMUIOffset );
780 id = (DWORD *)(buf + info->dwTypeIDMUIOffset);
781 ok( id[0] == RT_STRING, "type ID MUI[0] = %ld\n", id[0] );
782 ok( info->dwTypeNameMUIOffset == 102, "dwTypeNameMUIOffset = %ld\n", info->dwTypeNameMUIOffset );
783 str = (WCHAR *)(buf + info->dwTypeNameMUIOffset);
784 ok( !wcscmp(str, L"MUI"), "type name MUI[0] = %s\n", wine_dbgstr_w(str) );
785 str += wcslen(str) + 1;
786 ok( !str[0], "string list is not NULL terminated: %s\n", wine_dbgstr_w(str) );
787#if defined(__REACTOS__) && DLL_EXPORT_VERSION >= 0x600
788 }
789#endif
790
791 res = BeginUpdateResourceW( en_dll, TRUE );
792 ok( res != NULL, "BeginUpdateResourceW failed: %ld\n", GetLastError() );
793 r = UpdateResourceW( res, L"MUI", MAKEINTRESOURCEW(1), 0, &en_mui_res, sizeof(en_mui_res) );
794 ok( r, "UpdateResource failed: %ld\n", GetLastError() );
796 ok( r, "EndUpdateResourceW failed: %ld\n", GetLastError() );
797
798 memset( buf, 0xfe, sizeof(buf) );
799 size = sizeof(buf);
800 info->dwSize = sizeof(buf);
801 info->dwVersion = MUI_FILEINFO_VERSION;
802 r = GetFileMUIInfo( MUI_QUERY_TYPE | MUI_QUERY_CHECKSUM | MUI_QUERY_LANGUAGE_NAME
803 | MUI_QUERY_RESOURCE_TYPES, en_dll, info, &size );
804 ok( r, "GetFileMUIInfo failed: %ld\n", GetLastError() );
805 ok( info->dwSize == sizeof(buf), "dwSize = %ld\n", info->dwSize );
806 ok( info->dwVersion == MUI_FILEINFO_VERSION, "dwVersion = %ld\n", info->dwVersion );
807 ok( info->dwFileType == MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI, "dwFileType = %ld\n", info->dwFileType );
808 ok( info->pChecksum[0] == 'c', "pChecksum = %s\n",
809 wine_dbgstr_an((char *)info->pChecksum, sizeof(info->pChecksum)) );
810 ok( info->pServiceChecksum[0] == 's', "pServiceChecksum = %s\n",
811 wine_dbgstr_an((char *)info->pServiceChecksum, sizeof(info->pServiceChecksum)) );
812 ok( info->dwLanguageNameOffset == 72, "dwLanguageNameOffset = %ld\n", info->dwLanguageNameOffset );
813#if defined(__REACTOS__) && DLL_EXPORT_VERSION >= 0x600
814 if (is_reactos()) {
815 ok(FALSE, "FIXME: These tests crash on ReactOS!\n");
816 } else {
817#endif
818 str = (WCHAR *)(buf + info->dwLanguageNameOffset);
819 ok( !wcscmp(str, L"en-US"), "language name = %s\n", wine_dbgstr_w(str) );
820 ok( !info->dwTypeIDMainSize, "dwTypeIDMainSize = %ld\n", info->dwTypeIDMainSize );
821 ok( !info->dwTypeIDMainOffset, "dwTypeIDMainOffset = %ld\n", info->dwTypeIDMainOffset );
822 ok( !info->dwTypeNameMainOffset, "dwTypeNameMainOffset = %ld\n", info->dwTypeNameMainOffset );
823 ok( info->dwTypeIDMUISize == 1, "dwTypeIDMUISize = %ld\n", info->dwTypeIDMUISize );
824 ok( info->dwTypeIDMUIOffset == 84, "dwTypeIDMUIOffset = %ld\n", info->dwTypeIDMUIOffset );
825 id = (DWORD *)(buf + info->dwTypeIDMUIOffset);
826 ok( id[0] == RT_STRING, "type ID MUI[0] = %ld\n", id[0] );
827 ok( info->dwTypeNameMUIOffset == 88, "dwTypeNameMUIOffset = %ld\n", info->dwTypeNameMUIOffset );
828 str = (WCHAR *)(buf + info->dwTypeNameMUIOffset);
829 ok( !wcscmp(str, L"MUI"), "type name MUI[0] = %s\n", wine_dbgstr_w(str) );
830 str += wcslen(str) + 1;
831 ok( !str[0], "string list is not NULL terminated: %s\n", wine_dbgstr_w(str) );
832#if defined(__REACTOS__) && DLL_EXPORT_VERSION >= 0x600
833 }
834#endif
835
836 DeleteFileW( ln_dll );
837 DeleteFileW( en_dll );
838 RemoveDirectoryW( L"en-US" );
839#endif
840}
#define skip(...)
Definition: atltest.h:64
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
const char * wine_dbgstr_an(const char *str, int n)
Definition: compat.c:313
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
BOOL WINAPI UpdateResourceW(HANDLE hUpdate, LPCWSTR lpType, LPCWSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData)
Definition: res.c:1706
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint id
Definition: glext.h:5910
BOOL WINAPI GetFileMUIInfo(DWORD dwFlags, PCWSTR pcwszFilePath, PFILEMUIINFO pFileMUIInfo, DWORD *pcbFileMUIInfo)
Definition: vista.c:587
#define wine_dbgstr_w
Definition: kernel32.h:34
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static void create_test_dll(const WCHAR *name)
Definition: resource.c:592
static struct mui_res ln_mui_res
static struct mui_res en_mui_res
#define RT_STRING
Definition: pedump.c:368
#define RT_CURSOR
Definition: pedump.c:363
const WCHAR * str
#define is_reactos()
Definition: test.h:1041
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:373

Referenced by START_TEST().

◆ update_empty_exe()

static void update_empty_exe ( void  )
static

Definition at line 256 of file resource.c.

257{
259 BOOL r;
260
262 ok (file != INVALID_HANDLE_VALUE, "failed to create file\n");
263
264 CloseHandle( file );
265
267 if ( res != NULL || GetLastError() != ERROR_FILE_INVALID )
268 {
269 ok( res != NULL, "BeginUpdateResource failed\n");
270
271 /* check if it's possible to open the file now */
273 ok (test != INVALID_HANDLE_VALUE, "failed to create file\n");
274
275 CloseHandle( test );
276
278 ok( r == FALSE, "EndUpdateResource failed\n");
279 }
280 else
281 skip( "Can't update resource in empty file\n" );
282
284 ok( res == NULL, "BeginUpdateResource failed\n");
285}
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1697
#define test
Definition: rosglue.h:37
#define ERROR_FILE_INVALID
Definition: winerror.h:909

Referenced by START_TEST().

◆ update_missing_exe()

static void update_missing_exe ( void  )
static

Definition at line 246 of file resource.c.

247{
248 HANDLE res;
249
250 SetLastError(0xdeadbeef);
252 GLE = GetLastError();
253 ok( res == NULL, "BeginUpdateResource should fail\n");
254}

Referenced by START_TEST().

◆ update_resources_bigdata()

static void update_resources_bigdata ( void  )
static

Definition at line 341 of file resource.c.

342{
343 HANDLE res = NULL;
344 BOOL r;
345 char foo[2*page_size] = "foobar";
346
348 ok( res != NULL, "BeginUpdateResource succeeded\n");
349
351 MAKEINTRESOURCEA(0x3012),
352 MAKEINTRESOURCEA(0x5647),
353 0xcdba,
354 foo, sizeof foo );
355 ok( r == TRUE, "UpdateResource failed: %ld\n", GetLastError());
356
358 ok( r, "EndUpdateResource failed\n");
359}
BOOL WINAPI UpdateResourceA(HANDLE hUpdate, LPCSTR lpType, LPCSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData)
Definition: res.c:1738
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

Referenced by START_TEST().

◆ update_resources_delete()

static void update_resources_delete ( void  )
static

Definition at line 299 of file resource.c.

300{
301 HMODULE res;
302 BOOL r;
303
305 ok( res != NULL, "BeginUpdateResource failed\n");
306
308 ok( r, "EndUpdateResource failed\n");
309}

Referenced by START_TEST().

◆ update_resources_name()

static void update_resources_name ( void  )
static

Definition at line 361 of file resource.c.

362{
363 char foo[] = "resource data", res_name[] = "name", res_type[] = "type";
364 HANDLE res = NULL;
366 HRSRC rsrc;
367 BOOL ret;
368
370 ok( res != NULL, "BeginUpdateResource failed: %lu\n", GetLastError() );
371 if ( !res ) return;
372
373 ret = UpdateResourceA( res, res_type, res_name, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), foo, sizeof(foo) );
374 ok( ret == TRUE, "UpdateResource failed: %lu\n", GetLastError() );
375
377 ok( ret, "EndUpdateResource failed: %lu\n", GetLastError() );
378 if ( !ret ) return;
379
381 ok( module != NULL, "LoadLibraryEx failed: %lu\n", GetLastError() );
382 if ( !module ) return;
383
384 rsrc = FindResourceA( module, res_name, res_type );
385 ok( rsrc != NULL ||
387 "FindResource failed: %lu\n", GetLastError() );
388
390 ok( ret, "FreeLibrary failed: %lu\n", GetLastError() );
391}
#define broken(x)
Definition: atltest.h:178
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
return ret
Definition: mutex.c:146
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338

Referenced by START_TEST().

◆ update_resources_none()

static void update_resources_none ( void  )
static

Definition at line 287 of file resource.c.

288{
289 HMODULE res;
290 BOOL r;
291
293 ok( res != NULL, "BeginUpdateResource failed\n");
294
296 ok( r, "EndUpdateResource failed\n");
297}

Referenced by START_TEST().

◆ update_resources_version()

static void update_resources_version ( void  )
static

Definition at line 311 of file resource.c.

312{
313 HANDLE res = NULL;
314 BOOL r;
315 char foo[] = "red and white";
316
318 ok( res != NULL, "BeginUpdateResource failed\n");
319
320 if (0) /* this causes subsequent tests to fail on Vista */
321 {
323 MAKEINTRESOURCEA(0x1230),
324 MAKEINTRESOURCEA(0x4567),
325 0xabcd,
326 NULL, 0 );
327 ok( r == FALSE, "UpdateResource failed\n");
328 }
329
331 MAKEINTRESOURCEA(0x1230),
332 MAKEINTRESOURCEA(0x4567),
333 0xabcd,
334 foo, sizeof foo );
335 ok( r == TRUE, "UpdateResource failed: %ld\n", GetLastError());
336
338 ok( r, "EndUpdateResource failed: %ld\n", GetLastError());
339}

Referenced by START_TEST().

Variable Documentation

◆ 

const struct { ... } dll_image

Referenced by create_test_dll().

◆ dos

Definition at line 525 of file resource.c.

Referenced by build_exe(), and check_exe().

◆ en_mui_res

struct mui_res en_mui_res
static
Initial value:
= {
0xfecdfecd, sizeof(ln_mui_res), 0x10000, 0,
MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI >> 1,
0, 0, {'s','c'}, {'c'}, {0}, 0, 0, {0},
offsetof(struct mui_res, ln_type_names), sizeof(L"MUI\0"),
offsetof(struct mui_res, ln_type_ids), sizeof(ln_mui_res.ln_type_ids),
0, 0, 0, 0, offsetof(struct mui_res, lang), sizeof(L"en-US"), 0, 0,
{'M','U','I',0,0}, {RT_STRING}, {0}, {0}, {'e','n','-','U','S',0}
}
#define offsetof(TYPE, MEMBER)
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by test_mui().

◆ filename

const char filename[] = "test_.exe"
static

Definition at line 26 of file resource.c.

◆ filenameW

const WCHAR filenameW[] = {'t','e','s','t','_','.','e','x','e',0}
static

Definition at line 27 of file resource.c.

Referenced by test_internal_structure().

◆ GLE

DWORD GLE
static

Definition at line 28 of file resource.c.

Referenced by START_TEST(), and update_missing_exe().

◆ ln_mui_res

struct mui_res ln_mui_res
static
Initial value:
= {
0xfecdfecd, sizeof(ln_mui_res), 0x10000, 0,
MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN >> 1,
0, 0, {'s','c'}, {'c'}, {0}, 0, 0, {0},
offsetof(struct mui_res, ln_type_names), sizeof(L"MUI\0"),
offsetof(struct mui_res, ln_type_ids), sizeof(ln_mui_res.ln_type_ids),
offsetof(struct mui_res, mui_type_names), sizeof(L"MUI\0"),
offsetof(struct mui_res, mui_type_ids), sizeof(ln_mui_res.mui_type_ids), 0, 0,
offsetof(struct mui_res, fallback_lang), sizeof(L"en-US"),
{'M','U','I',0,0}, {RT_CURSOR}, {'M','U','I',0,0}, {RT_STRING}, {0}, {'e','n','-','U','S',0},
}

Referenced by test_mui().

◆ nt

Definition at line 526 of file resource.c.

Referenced by build_exe(), and check_exe().

◆ sec_variants

const struct _sec_variants sec_variants[]
static

Referenced by START_TEST().

◆ section

Definition at line 527 of file resource.c.

◆ sh_junk

const IMAGE_SECTION_HEADER sh_junk
static
Initial value:
=
{
".reloc\0", {page_size}, 4*page_size, page_size, 4*page_size, 0, 0, 0, 0,
}
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240

Definition at line 93 of file resource.c.

◆ sh_junk_2

const IMAGE_SECTION_HEADER sh_junk_2
static
Initial value:

Definition at line 100 of file resource.c.

◆ sh_rodata_1

const IMAGE_SECTION_HEADER sh_rodata_1
static
Initial value:

Definition at line 37 of file resource.c.

◆ sh_rodata_2

const IMAGE_SECTION_HEADER sh_rodata_2
static
Initial value:

Definition at line 44 of file resource.c.

◆ sh_rsrc_1

const IMAGE_SECTION_HEADER sh_rsrc_1
static
Initial value:

Definition at line 51 of file resource.c.

◆ sh_rsrc_2

const IMAGE_SECTION_HEADER sh_rsrc_2
static
Initial value:

Definition at line 58 of file resource.c.

◆ sh_rsrc_3

const IMAGE_SECTION_HEADER sh_rsrc_3
static
Initial value:

Definition at line 65 of file resource.c.

◆ sh_rsrc_4

const IMAGE_SECTION_HEADER sh_rsrc_4
static
Initial value:

Definition at line 72 of file resource.c.

◆ sh_rsrc_5

const IMAGE_SECTION_HEADER sh_rsrc_5
static
Initial value:

Definition at line 79 of file resource.c.

◆ sh_rsrc_6

const IMAGE_SECTION_HEADER sh_rsrc_6
static
Initial value:

Definition at line 86 of file resource.c.