ReactOS  0.4.14-dev-552-g2fad488
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
 

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 check_exe (const sec_verify *verify)
 
static void test_find_resource (void)
 
 START_TEST (resource)
 

Variables

static const char filename [] = "test_.exe"
 
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 []
 

Typedef Documentation

◆ sec_build

◆ sec_verify

Enumeration Type Documentation

◆ constants

Enumerator
page_size 
rva_rsrc_start 
max_sections 

Definition at line 29 of file resource.c.

29  {
30  page_size = 0x1000,
32  max_sections = 3
33 };

Function Documentation

◆ build_exe()

static int build_exe ( const sec_build sec_descr)
static

Definition at line 161 of file resource.c.

162 {
167  HANDLE file;
168  DWORD written, i, file_size;
170 
171  memset( page, 0, sizeof page );
172 
173  dos = (void*) page;
175  dos->e_lfanew = sizeof *dos;
176 
177  nt = (void*) &dos[1];
178 
184 
185  opt = &nt->OptionalHeader;
186 
188  opt->MajorLinkerVersion = 1;
189  opt->BaseOfCode = 0x10;
190  opt->ImageBase = 0x10000000;
192  opt->MajorImageVersion = 1;
193  opt->MajorSubsystemVersion = 4;
194  opt->SizeOfHeaders = sizeof *dos + sizeof *nt + sizeof *sec * 2;
195  opt->SizeOfImage = page_size;
197 
198  /* if SectionAlignment and File alignment are not specified */
199  /* UpdateResource fails trying to create a huge temporary file */
201  opt->FileAlignment = page_size;
202 
205 
206  sec = (void*) &nt[1];
207 
208  file_size = 0;
209  for ( i = 0; i < max_sections; i++ )
210  if ( sec_descr->sect_in[i] )
211  {
212  DWORD virt_end_of_section = sec_descr->sect_in[i]->Misc.VirtualSize +
213  sec_descr->sect_in[i]->VirtualAddress;
214  DWORD phys_end_of_section = sec_descr->sect_in[i]->SizeOfRawData +
215  sec_descr->sect_in[i]->PointerToRawData;
216  memcpy( sec + nt->FileHeader.NumberOfSections, sec_descr->sect_in[i],
217  sizeof(sec[0]) );
219  if ( opt->SizeOfImage < virt_end_of_section )
220  opt->SizeOfImage = virt_end_of_section;
221  if ( file_size < phys_end_of_section )
222  file_size = phys_end_of_section;
223  }
224 
226  ok (file != INVALID_HANDLE_VALUE, "failed to create file\n");
227 
228  /* write out the header */
229  WriteFile( file, page, sizeof page, &written, NULL );
230 
231  /* write out zeroed pages for sections */
232  memset( page, 0, sizeof page );
233  for ( i = page_size; i < file_size; i += page_size )
234  {
236  WriteFile( file, page, size, &written, NULL );
237  }
238 
239  CloseHandle( file );
240 
241  return 0;
242 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:406
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD PointerToRawData
Definition: pedump.c:290
const char * filename
Definition: ioapi.h:135
IMAGE_NT_HEADERS nt
Definition: module.c:50
#define IMAGE_FILE_DLL
Definition: pedump.c:169
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
WORD MajorOperatingSystemVersion
Definition: ntddk_ex.h:160
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
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
#define GENERIC_WRITE
Definition: nt_native.h:90
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
Definition: ntimage.h:438
smooth NULL
Definition: ftsmooth.c:416
Definition: module.h:566
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
GLsizeiptr size
Definition: glext.h:5919
const char file[]
Definition: icontest.c:11
const IMAGE_SECTION_HEADER * sect_in[max_sections]
Definition: resource.c:107
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
unsigned long DWORD
Definition: ntddk_ex.h:95
IMAGE_DOS_HEADER dos
Definition: module.c:49
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define CREATE_ALWAYS
Definition: disk.h:72
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define IMAGE_NT_OPTIONAL_HDR_MAGIC
Definition: ntimage.h:387
#define IMAGE_FILE_RESOURCE_DIRECTORY
Definition: winnt_old.h:647
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
#define memset(x, y, z)
Definition: compat.h:39
union _IMAGE_SECTION_HEADER::@1543 Misc
#define file_size(inode)
Definition: reiserfs_fs.h:1869
Definition: fci.c:126

Referenced by START_TEST().

◆ check_exe()

static void check_exe ( const sec_verify verify)
static

Definition at line 359 of file resource.c.

360 {
361  int i;
368  DWORD length, sec_count = 0;
369 
371  ok (file != INVALID_HANDLE_VALUE, "failed to create file (%d)\n", GetLastError());
372 
373  length = GetFileSize( file, NULL );
374  ok( length >= verify->length, "file size wrong\n");
375 
377  ok (mapping != NULL, "failed to create file\n");
378 
380  ok( dos != NULL, "failed to map file\n");
381 
382  if (!dos)
383  goto end;
384 
385  nt = (void*) ((BYTE*) dos + dos->e_lfanew);
386  opt = &nt->OptionalHeader;
387  sec = (void*) &nt[1];
388 
389  for(i = 0; i < max_sections; i++)
390  if (verify->sect_out[i])
391  {
392  ok( !memcmp(&verify->sect_out[i]->Name, &sec[sec_count].Name, 8), "section %d name wrong\n", sec_count);
393  ok( verify->sect_out[i]->VirtualAddress == sec[sec_count].VirtualAddress, "section %d vaddr wrong\n", sec_count);
394  ok( verify->sect_out[i]->SizeOfRawData <= sec[sec_count].SizeOfRawData, "section %d SizeOfRawData wrong (%d vs %d)\n", sec_count, verify->sect_out[i]->SizeOfRawData ,sec[sec_count].SizeOfRawData);
395  ok( verify->sect_out[i]->PointerToRawData == sec[sec_count].PointerToRawData, "section %d PointerToRawData wrong\n", sec_count);
396  ok( verify->sect_out[i]->Characteristics == sec[sec_count].Characteristics , "section %d characteristics wrong\n", sec_count);
397  sec_count++;
398  }
399 
400  ok( nt->FileHeader.NumberOfSections == sec_count, "number of sections wrong\n" );
401 
402  if (verify->rsrc_section >= 0 && verify->rsrc_section < nt->FileHeader.NumberOfSections)
403  {
404  dir = (void*) ((BYTE*) dos + sec[verify->rsrc_section].VirtualAddress);
405 
406  ok( dir->Characteristics == 0, "Characteristics wrong\n");
407  ok( dir->TimeDateStamp == 0 || abs( dir->TimeDateStamp - GetTickCount() ) < 1000 /* nt4 */,
408  "TimeDateStamp wrong %u\n", dir->TimeDateStamp);
409  ok( dir->MajorVersion == 4, "MajorVersion wrong\n");
410  ok( dir->MinorVersion == 0, "MinorVersion wrong\n");
411 
412  ok( dir->NumberOfNamedEntries == verify->NumberOfNamedEntries, "NumberOfNamedEntries should be %d instead of %d\n",
413  verify->NumberOfNamedEntries, dir->NumberOfNamedEntries);
414  ok( dir->NumberOfIdEntries == verify->NumberOfIdEntries, "NumberOfIdEntries should be %d instead of %d\n",
415  verify->NumberOfIdEntries, dir->NumberOfIdEntries);
416 
417  ok(opt->DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY].VirtualAddress == sec[verify->rsrc_section].VirtualAddress,
418  "VirtualAddress in optional header should be %d instead of %d\n",
419  sec[verify->rsrc_section].VirtualAddress, opt->DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY].VirtualAddress);
420  }
421 
422 end:
423  UnmapViewOfFile( dos );
424 
425  CloseHandle( mapping );
426 
427  CloseHandle( file );
428 }
int rsrc_section
Definition: resource.c:114
#define abs(i)
Definition: fconv.c:206
#define CloseHandle
Definition: compat.h:406
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define MapViewOfFile
Definition: compat.h:410
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint GLuint end
Definition: gl.h:1545
DWORD PointerToRawData
Definition: pedump.c:290
const char * filename
Definition: ioapi.h:135
IMAGE_NT_HEADERS nt
Definition: module.c:50
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
DWORD length
Definition: resource.c:113
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
DWORD NumberOfNamedEntries
Definition: resource.c:115
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:435
unsigned int dir
Definition: maze.c:112
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
#define OPEN_EXISTING
Definition: compat.h:434
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
IMAGE_DOS_HEADER dos
Definition: module.c:49
const IMAGE_SECTION_HEADER * sect_out[max_sections]
Definition: resource.c:112
unsigned char BYTE
Definition: mem.h:68
#define GENERIC_READ
Definition: compat.h:124
DWORD NumberOfIdEntries
Definition: resource.c:115
#define ok(value,...)
Definition: atltest.h:57
#define PAGE_READONLY
Definition: compat.h:127
BYTE Name[IMAGE_SIZEOF_SHORT_NAME]
Definition: pedump.c:281
#define IMAGE_FILE_RESOURCE_DIRECTORY
Definition: winnt_old.h:647
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
#define UnmapViewOfFile
Definition: compat.h:411
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
Definition: fci.c:126

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( resource  )

Definition at line 466 of file resource.c.

467 {
468  DWORD i;
469 
472 
474  {
475  win_skip("Resource calls are not implemented\n");
476  return;
477  }
478 
480 
481  for(i=0; i < sizeof( sec_variants ) / sizeof( sec_variants[0] ); i++)
482  {
483  const struct _sec_variants *sec = &sec_variants[i];
484  build_exe( &sec->build );
486  check_exe( &sec->chk_none );
488  check_exe( &sec->chk_delete );
490  check_exe( &sec->chk_version );
492  check_exe( &sec->chk_bigdata );
494  }
496 }
static void update_resources_none(void)
Definition: resource.c:285
static int build_exe(const sec_build *sec_descr)
Definition: resource.c:161
static void check_exe(const sec_verify *verify)
Definition: resource.c:359
static void update_resources_delete(void)
Definition: resource.c:297
static DWORD GLE
Definition: resource.c:27
const char * filename
Definition: ioapi.h:135
static void update_resources_bigdata(void)
Definition: resource.c:339
static void update_empty_exe(void)
Definition: resource.c:254
sec_verify chk_none
Definition: resource.c:121
static const struct _sec_variants sec_variants[]
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
static void update_resources_version(void)
Definition: resource.c:309
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
sec_verify chk_delete
Definition: resource.c:121
sec_build build
Definition: resource.c:120
static void update_missing_exe(void)
Definition: resource.c:244
sec_verify chk_version
Definition: resource.c:121
unsigned long DWORD
Definition: ntddk_ex.h:95
sec_verify chk_bigdata
Definition: resource.c:121
static void test_find_resource(void)
Definition: resource.c:430
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:150

◆ test_find_resource()

static void test_find_resource ( void  )
static

Definition at line 430 of file resource.c.

431 {
432  HRSRC rsrc;
433 
435  ok( rsrc != 0, "resource not found\n" );
438  ok( rsrc != 0, "resource not found\n" );
441  ok( rsrc != 0, "resource not found\n" );
442 
443  SetLastError( 0xdeadbeef );
445  ok( !rsrc, "resource found\n" );
446  ok( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "wrong error %u\n", GetLastError() );
447 
448  SetLastError( 0xdeadbeef );
450  ok( !rsrc, "resource found\n" );
451  ok( GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "wrong error %u\n", GetLastError() );
452 
453  SetLastError( 0xdeadbeef );
456  ok( !rsrc, "resource found\n" );
457  ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() );
458 
459  SetLastError( 0xdeadbeef );
462  ok( !rsrc, "resource found\n" );
463  ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() );
464 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ERROR_RESOURCE_NAME_NOT_FOUND
Definition: winerror.h:1121
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SUBLANG_NEUTRAL
Definition: nls.h:167
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
smooth NULL
Definition: ftsmooth.c:416
#define RT_DIALOG
Definition: pedump.c:367
#define SetLastError(x)
Definition: compat.h:417
#define LANG_ENGLISH
Definition: nls.h:52
HRSRC WINAPI FindResourceExW(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang)
Definition: res.c:164
#define LANG_FRENCH
Definition: nls.h:58
#define LANG_GERMAN
Definition: nls.h:62
#define RT_MENU
Definition: pedump.c:366
#define ERROR_RESOURCE_LANG_NOT_FOUND
Definition: winerror.h:1122
#define ok(value,...)
Definition: atltest.h:57
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
#define MAKELANGID(p, s)
Definition: nls.h:15
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ERROR_RESOURCE_TYPE_NOT_FOUND
Definition: winerror.h:1120

Referenced by START_TEST().

◆ update_empty_exe()

static void update_empty_exe ( void  )
static

Definition at line 254 of file resource.c.

255 {
256  HANDLE file, res, test;
257  BOOL r;
258 
260  ok (file != INVALID_HANDLE_VALUE, "failed to create file\n");
261 
262  CloseHandle( file );
263 
265  if ( res != NULL || GetLastError() != ERROR_FILE_INVALID )
266  {
267  ok( res != NULL, "BeginUpdateResource failed\n");
268 
269  /* check if it's possible to open the file now */
271  ok (test != INVALID_HANDLE_VALUE, "failed to create file\n");
272 
273  CloseHandle( test );
274 
276  ok( r == FALSE, "EndUpdateResource failed\n");
277  }
278  else
279  skip( "Can't update resource in empty file\n" );
280 
282  ok( res == NULL, "BeginUpdateResource failed\n");
283 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
const char file[]
Definition: icontest.c:11
#define GENERIC_READ
Definition: compat.h:124
#define CREATE_ALWAYS
Definition: disk.h:72
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
#define ERROR_FILE_INVALID
Definition: winerror.h:585
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
Definition: fci.c:126
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1697

Referenced by START_TEST().

◆ update_missing_exe()

static void update_missing_exe ( void  )
static

Definition at line 244 of file resource.c.

245 {
246  HANDLE res;
247 
248  SetLastError(0xdeadbeef);
250  GLE = GetLastError();
251  ok( res == NULL, "BeginUpdateResource should fail\n");
252 }
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static DWORD GLE
Definition: resource.c:27
const char * filename
Definition: ioapi.h:135
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
GLuint res
Definition: glext.h:9613

Referenced by START_TEST().

◆ update_resources_bigdata()

static void update_resources_bigdata ( void  )
static

Definition at line 339 of file resource.c.

340 {
341  HANDLE res = NULL;
342  BOOL r;
343  char foo[2*page_size] = "foobar";
344 
346  ok( res != NULL, "BeginUpdateResource succeeded\n");
347 
348  r = UpdateResourceA( res,
349  MAKEINTRESOURCEA(0x3012),
350  MAKEINTRESOURCEA(0x5647),
351  0xcdba,
352  foo, sizeof foo );
353  ok( r == TRUE, "UpdateResource failed: %d\n", GetLastError());
354 
356  ok( r, "EndUpdateResource failed\n");
357 }
#define TRUE
Definition: types.h:120
BOOL WINAPI UpdateResourceA(HANDLE hUpdate, LPCSTR lpType, LPCSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData)
Definition: res.c:1738
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
GLuint res
Definition: glext.h:9613
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1697

Referenced by START_TEST().

◆ update_resources_delete()

static void update_resources_delete ( void  )
static

Definition at line 297 of file resource.c.

298 {
299  HMODULE res;
300  BOOL r;
301 
303  ok( res != NULL, "BeginUpdateResource failed\n");
304 
306  ok( r, "EndUpdateResource failed\n");
307 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
GLuint res
Definition: glext.h:9613
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1697

Referenced by START_TEST().

◆ update_resources_none()

static void update_resources_none ( void  )
static

Definition at line 285 of file resource.c.

286 {
287  HMODULE res;
288  BOOL r;
289 
291  ok( res != NULL, "BeginUpdateResource failed\n");
292 
294  ok( r, "EndUpdateResource failed\n");
295 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
GLuint res
Definition: glext.h:9613
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1697

Referenced by START_TEST().

◆ update_resources_version()

static void update_resources_version ( void  )
static

Definition at line 309 of file resource.c.

310 {
311  HANDLE res = NULL;
312  BOOL r;
313  char foo[] = "red and white";
314 
316  ok( res != NULL, "BeginUpdateResource failed\n");
317 
318  if (0) /* this causes subsequent tests to fail on Vista */
319  {
320  r = UpdateResourceA( res,
321  MAKEINTRESOURCEA(0x1230),
322  MAKEINTRESOURCEA(0x4567),
323  0xabcd,
324  NULL, 0 );
325  ok( r == FALSE, "UpdateResource failed\n");
326  }
327 
328  r = UpdateResourceA( res,
329  MAKEINTRESOURCEA(0x1230),
330  MAKEINTRESOURCEA(0x4567),
331  0xabcd,
332  foo, sizeof foo );
333  ok( r == TRUE, "UpdateResource failed: %d\n", GetLastError());
334 
336  ok( r, "EndUpdateResource failed: %d\n", GetLastError());
337 }
#define TRUE
Definition: types.h:120
BOOL WINAPI UpdateResourceA(HANDLE hUpdate, LPCSTR lpType, LPCSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData)
Definition: res.c:1738
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI BeginUpdateResourceA(LPCSTR pFileName, BOOL bDeleteExistingResources)
Definition: res.c:1657
GLuint res
Definition: glext.h:9613
BOOL WINAPI EndUpdateResourceA(HANDLE hUpdate, BOOL fDiscard)
Definition: res.c:1697

Referenced by START_TEST().

Variable Documentation

◆ filename

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

Definition at line 26 of file resource.c.

◆ GLE

DWORD GLE
static

Definition at line 27 of file resource.c.

Referenced by START_TEST(), and update_missing_exe().

◆ sec_variants

const struct _sec_variants sec_variants[]
static

Referenced by START_TEST().

◆ 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_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 92 of file resource.c.

◆ sh_junk_2

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

Definition at line 99 of file resource.c.

◆ sh_rodata_1

const IMAGE_SECTION_HEADER sh_rodata_1
static
Initial value:
=
{
".rodata", {2*page_size}, page_size, 2*page_size, page_size, 0, 0, 0, 0,
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 36 of file resource.c.

◆ sh_rodata_2

const IMAGE_SECTION_HEADER sh_rodata_2
static
Initial value:
=
{
".rodata", {page_size}, page_size, page_size, page_size, 0, 0, 0, 0,
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 43 of file resource.c.

◆ sh_rsrc_1

const IMAGE_SECTION_HEADER sh_rsrc_1
static
Initial value:
=
{
".rsrc\0\0", {page_size}, rva_rsrc_start, page_size, rva_rsrc_start, 0, 0, 0, 0,
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 50 of file resource.c.

◆ sh_rsrc_2

const IMAGE_SECTION_HEADER sh_rsrc_2
static
Initial value:
=
{
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 57 of file resource.c.

◆ sh_rsrc_3

const IMAGE_SECTION_HEADER sh_rsrc_3
static
Initial value:
=
{
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 64 of file resource.c.

◆ sh_rsrc_4

const IMAGE_SECTION_HEADER sh_rsrc_4
static
Initial value:
=
{
".rsrc\0\0", {3*page_size}, rva_rsrc_start, 3*page_size, rva_rsrc_start, 0, 0, 0, 0,
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 71 of file resource.c.

◆ sh_rsrc_5

const IMAGE_SECTION_HEADER sh_rsrc_5
static
Initial value:
=
{
".rsrc\0\0", {3*page_size}, 2*page_size, 3*page_size, 2*page_size, 0, 0, 0, 0,
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 78 of file resource.c.

◆ sh_rsrc_6

const IMAGE_SECTION_HEADER sh_rsrc_6
static
Initial value:
=
{
".rsrc\0\0", {page_size}, rva_rsrc_start, 8, rva_rsrc_start, 0, 0, 0, 0,
}
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231

Definition at line 85 of file resource.c.